4.3BSD/usr/contrib/X/xted/start_up.clu

# extend

qs = sequence[string]
qi = sequence[int]

qp = sequence[eproc]
tab = qp$[run_ctrlat, run_ctrla, run_ctrlb, run_ctrlat,
	  run_ctrld, run_ctrle, run_ctrlf, run_ctrlg,
	  ed_help, insert_char, run_interactive, run_ctrlk,
	  run_ctrll, run_ctrlm, run_ctrlnp, run_ctrlo,
	  run_ctrlnp, run_ctrlq, run_ctrlr, run_ctrls,
	  run_ctrlt, run_ctrlu, run_ctrlv, run_ctrlw,
	  run_ctrlx, run_ctrly, incremental_update, run_ctrlsk,
	  indyan, run_adjust, run_ctrlsn, run_ctrlso]

start_up = proc ()
    own done: bool := false
    jcl: string := get_jcl()
    options: qs := qs$new()
    while ~string$empty(jcl)  cand
	  (jcl[1] = '-'  cor  jcl[1] = ':'  cor  jcl[1] = '=') do
	i: int := string$indexc(' ', jcl)
	s: string
	if i = 0
	   then s := jcl
		jcl := ""
	   else s := string$substr(jcl, 1, i - 1)
		jcl := string$rest(jcl, i + 1)
	   end
	options := qs$addh(options, s)
	end
    while jcl[1] = ' ' do
	jcl := string$rest(jcl, 2)
	end except when bounds: end
    _reset_input()
    screen$init(options)
    e: env
    if done
       then e := winset$reset()
       else _gc$control(2**18 - 2**15, 2**17 - 1)
	    e := env$create(false)
	    bufset$init()
	    winset$init(e)
	    bufset$display(e, bufset$create_buf("Main", "", e.buffer))
	    chtab: vec := vec$fill(0, 128, insert_char)
	    for i: int in qp$indexes(tab) do
		chtab[i - 1] := tab[i]
		end
	    chtab[c2i(del)] := run_del
	    e.chtab := chtab
	    e.title := "---- Buffer: Main (type ^H for help)"
	    nlines, nchars: int := _get_screen_size()
	    e.top_line := 1
	    e.size := nlines - 2
	    e.width := nchars - 1
	    umask: int := _umask(0)
	    env$store_num(e, "umask", umask)
	    env$store_num(e, "write_mode", i_and(0666, -umask - 1))
	    env$store_str(e, "terminal", "vs100")
	    env$store_str(e, "host", _host_name())
	    done := true
       end except when not_possible (*): end
    env$clear(e)
    if ~string$empty(jcl)
       then _push_macro_chars(c2s(ctrlr) || jcl || "\r") end
    macro_file(e, fname$create(_environ("HOME"), "", "ted_init", ""))
       except when not_found, not_possible (*): end
    ted(e)
    end start_up