;	EMACS.RC:	Standard micro Startup program
;			for MicroEMACS 3.9d and above
;			(C)opyright 1987 by Daniel M Lawrence
;			Last Update: 10/20/87

set $discmd FALSE
write-message "[Setting up....]"

; If you screen "SNOWS", uncomment this line
;	set $flicker "TRUE"

; To use an IBM-PC EGA card, uncomment the following line
;	set $sres "EGA"

;	***** Rebind the Function key group

bind-to-key search-forward		FN;
bind-to-key search-reverse		FN<
bind-to-key hunt-forward		FN=
bind-to-key hunt-backward		FN>
bind-to-key execute-macro-1		FN?
bind-to-key execute-macro-2		FN@
bind-to-key next-window			FNA
bind-to-key execute-macro-3		FNB
bind-to-key save-file			FNC
bind-to-key exit-emacs			FND

bind-to-key execute-macro-10		FNT
bind-to-key execute-macro-11		FNU
bind-to-key execute-macro-12		FNV
bind-to-key execute-macro-13		FNW
bind-to-key execute-macro-14		FNX
bind-to-key execute-macro-15		FNY
bind-to-key execute-macro-16		FNZ
bind-to-key execute-macro-17		FN[
bind-to-key execute-macro-18		FN\
bind-to-key execute-macro-19		FN]

;	Set Default Global modes

add-global-mode "blue"
;bind-to-key meta-prefix `

;	Toggle function key window display

1	store-macro
	!if %rcfkeys
		!goto rcfoff
	!endif

;	toggle function key window on
	save-window
	1 next-window
	!if &sequal $cbufname "emacs.hlp"
		delete-window
	!endif
	!if &not &sequal $cbufname "Function Keys"
		1 split-current-window
		select-buffer "Function Keys"
		add-mode "red"
		!force 5 resize-window
		1 goto-line
	!endif
	set %rcfkeys TRUE
	!force restore-window
	!if &sequal $cbufname "Function Keys"
		next-window
	!endif
	write-message "[Function key window ON]"
	!return

	;Toggle the function key window off
*rcfoff
	save-window
	1 next-window
	!if &sequal "Function Keys" $cbufname
		delete-window
	!endif
	!force restore-window
	write-message "[Function key window OFF]"
	set %rcfkeys FALSE
!endm

;	Toggle HELP file onscreen

2 store-macro
	1 next-window

	;Make sure the function key window isn't up!
	!if &sequal $cbufname "Function Keys"
		delete-window
	!endif
	set %rcfkeys FALSE

	;Bring up page 1
	!if &not &seq $cbufname "emacs.hlp"
		help
		8 resize-window
		add-mode "red"
		beginning-of-file
		2 forward-character
	!endif

*rchelp

	write-message "[PgUp/PgDn] Page    [FN6] EXIT     ^G  Exit leaving page on screen"
	update-screen
	set %rctmp &gtkey
	!if &equ &asc %rctmp 0
		set %rctmp &gtkey
		!if &seq %rctmp I
			beginning-of-line
			!force search-reverse "=>"
			1 redraw-display
			!goto rchelp
		!endif
		!if &seq %rctmp Q
			beginning-of-line
			2 forward-character
			!force search-forward "=>"
			1 redraw-display
			!goto rchelp
		!endif
		!if &seq %rctmp "~@"
			delete-window
			!if &seq %rcfkeys TRUE
				set %rcfkeys FALSE
				execute-macro-1
			!endif
			write-message "[Help Exited]"
			!return
		!endif
	!endif
	!if &equ &asc %rctmp 7
		next-window
		set %rcfkeys FALSE
		write-message "[Help Aborted]"
		!return
	!endif
	!goto rchelp
!endm

;	Load a new page

3	store-macro
	!if &seq &find newpage.cmd ""
		write-message "[Can not find NEWPAGE.CMD]"
		!return
	!endif
	execute-file newpage.cmd
!endm

;procedure to clean out the current page (which is nothing right now)

store-procedure	clean
	; nothing by default
!endm

;	Set up auto CMODE

20	store-macro
	set %rctmp &sin $cfname "."
	!if &equ %rctmp 0
		!return
	!endif
	set %rctmp &mid $cfname &add %rctmp 1 5
	!if &or &seq %rctmp "c" &seq %rctmp "h"
		add-mode "cmode"
	!endif
!endm
bind-to-key execute-macro-20	M-FNR

;	bring up the function key window

	1 split-current-window
	select-buffer "Function Keys"
	insert-string "f1 search-> f2 <-search Û    MicroEMACS:  Text Editor~n"
	insert-string "f3 hunt->   f4 <-hunt   Û ~n"
	insert-string "f5 fkeys    f6 help     Û  Available function key Pages include:~n"
	insert-string "f7 nxt wind f8 pg[    ] Û    WORD  PROG  BOX~n"
	insert-string "f9 save     f10 exit    Û  [use the f8 key to load Pages]~n"
	unmark-buffer
	delete-window
	set %rcfkeys FALSE
	execute-macro-1
	set $discmd TRUE
Û
