diff --git a/README.md b/README.md index d5e543c4a3d077..ab4c76e4ede2e6 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,8 @@ The following [help document](runtime_tos/doc/os_atari.txt) can also be viewed i *TOS_01* Introduction *atari* The distribution contains tiny, small and normal feature builds. The -executables are named vimt.ttp, vims.ttp and vim.ttp respectively. +executables are named vimt.ttp, vims.ttp and vim.ttp respectively. There are +also 68020-60 builds of each. vimt.ttp starts and quits much faster than vim.ttp and is also much smaller (~450Kb vs. ~1Mb) but has far fewer features (e.g. splits, command windows and @@ -32,13 +33,6 @@ eval are missing). Use the :version command to check what features a build has. -Advanced features such as tags and syntax highlighting are slow, even on -an accelerated machine. Tags are usable as long as tag files are kept -reasonably small. Syntax highlighting performance can be improved a little by -limiting the number of columns that are parsed (set synmaxcol=n). -Core features perform quite well. You might need to experiment with Vim -options to make things work. - ============================================================================== *TOS_02* Installation @@ -73,32 +67,31 @@ They could be used to conditionally set options in your vimrc. You may need to test for the availability of a feature in vimrc. Do this using has(), e.g. - if has("compiler") - compiler DEVPAC - endif - - if has("eval") - color BLUE - endif +if has("eval") + compiler DEVPAC + color BLUE +endif - if has("eval") && v:os=="TOS" - " set options, define functions. Whatever you want - endif +if has("eval") && v:os=="TOS" + " set options, define functions. Whatever you want +endif ATARI Vim looks for vimrc files in the usual places. Check where these are using the :version command. +It is recommended to store user files in $HOME\vimfiles. + ============================================================================== *TOS_03* Using a Shell *shell* *gulam* Any shell that sets the _shell_p vector can be used, e.g. Gulam. -:lmake and :lopen can be used in vim.ttp. By default Vim attempts to execute the -make utility in the current working directory. If make is not installed, the -simplest way to get this to work is to create a shell script called 'make.g'. +:lmake and :lopen can be used in vim.ttp. By default Vim attempts to execute +the make utility in the current working directory. If make is not installed, +the simplest way to get this to work is to create a shell script. -e.g. make.g might contain: +e.g. 'make.g' might contain: d:\devpac\gen.ttp main.s @@ -110,17 +103,18 @@ Then to make, use: :lmake -The cut down runtime includes compiler files for gcc and devpac. These files -will format the error output from these programs for display by :lopen. +The cut down runtime includes compiler files for gcc, devpac and vasm. These +files will format the error output from these programs for display by :lopen. For devpac you will need to set the default compiler first. Do this with the command: :compiler DEVPAC + :compiler to enumerate them ============================================================================== -*TOS_04* Setting the Palette *paltos* *palvim* *palmap* *color* +*TOS_04* Setting the Palette *paltos* *palvim* *palmap* *sane* Vim colours are numbered thus: @@ -191,13 +185,19 @@ e.g. will map colour index 10 to Vim colour number 0 etc +:sane + +Will restore your palette and resolution to their startup values. + ============================================================================== *TOS_05* Changing Resolution *rez* :rez will display the current resolution. -:rez name will set the named resolution +:rez name will set the named resolution. :rez will allow you to through all valid resolutions. +:sane will restore your palette and resolution to their startup + values. When Vim is quit, the startup resolution is restored. @@ -207,7 +207,7 @@ The current resolution is stored in the variable |v:resolution|. *TOS_06* Changing the Keyboard Repeat Rate *Kbrate* -:Kbrate Display the current setting +:Kbrate Display the current setting. :Kbrate initial every Set keypresses to repeat after an initial number of ticks and then every n 50/60Hz ticks. @@ -227,4 +227,6 @@ Changes to the existing code are wrapped with the 'TOS' macro. All os_atari_* files and Make_tos.mak are specific to this port. ============================================================================== + +vim:tw=78:ts=8:ft=help:norl:noexpandtab: ``` diff --git a/README_tos.txt b/README_tos.txt index e69de29bb2d1d6..ab4c76e4ede2e6 100644 --- a/README_tos.txt +++ b/README_tos.txt @@ -0,0 +1,232 @@ +## Vim 7.4 for ATARI ST/TOS + +[View the original README](README.txt) + +The following [help document](runtime_tos/doc/os_atari.txt) can also be viewed in Vim using + +`:help atari` + +``` +*os_atari.txt* For Vim version 7.4. Last change: Sep 2024 + + Notes on the Atari TOS Port + +|TOS_01| Introduction +|TOS_02| Installation +|TOS_03| Using a Shell +|TOS_04| Setting the Palette +|TOS_05| Changing Resolution +|TOS_06| Changing the Keyboard Repeat Rate +|TOS_07| Development + +============================================================================== + +*TOS_01* Introduction *atari* + +The distribution contains tiny, small and normal feature builds. The +executables are named vimt.ttp, vims.ttp and vim.ttp respectively. There are +also 68020-60 builds of each. + +vimt.ttp starts and quits much faster than vim.ttp and is also much smaller +(~450Kb vs. ~1Mb) but has far fewer features (e.g. splits, command windows and +eval are missing). + +Use the :version command to check what features a build has. + +============================================================================== + +*TOS_02* Installation + +The distribution includes a cut down runtime. You may use the full Vim runtime +(or add files to it) if you wish but having fewer files to glob improves +performance. + +You should set the following environment variables in your shell: +VIM +VIMRUNTIME +HOME +TMP + +However, if not set the following defaults are used: +VIM=C:\VIM +VIMRUNTIME=C:\VIM\RT + +The following variables are available in the normal build (which supports the +'eval' feature): + +*v:resolution* The current resolution. + Either st-{low,med,hi}, tt-{low,med,hi} or a Falcon mode + such as 320x200, 384x240 etc +*v:machine* The current machine. + Either ST, STe, TT, Falcon or unknown +*v:os* The current OS. + Either TOS, MagiC, MiNT or Geneva + +They could be used to conditionally set options in your vimrc. + +You may need to test for the availability of a feature in vimrc. Do this +using has(), e.g. + +if has("eval") + compiler DEVPAC + color BLUE +endif + +if has("eval") && v:os=="TOS" + " set options, define functions. Whatever you want +endif + +ATARI Vim looks for vimrc files in the usual places. Check where these are +using the :version command. + +It is recommended to store user files in $HOME\vimfiles. + +============================================================================== + +*TOS_03* Using a Shell *shell* *gulam* + +Any shell that sets the _shell_p vector can be used, e.g. Gulam. + +:lmake and :lopen can be used in vim.ttp. By default Vim attempts to execute +the make utility in the current working directory. If make is not installed, +the simplest way to get this to work is to create a shell script. + +e.g. 'make.g' might contain: + +d:\devpac\gen.ttp main.s + +You will also need to set the make program like so: + + :set makeprg=make.g + +Then to make, use: + + :lmake + +The cut down runtime includes compiler files for gcc, devpac and vasm. These +files will format the error output from these programs for display by :lopen. + +For devpac you will need to set the default compiler first. Do this with the +command: + + :compiler DEVPAC + :compiler to enumerate them + +============================================================================== + +*TOS_04* Setting the Palette *paltos* *palvim* *palmap* *sane* + +Vim colours are numbered thus: + +0 Black +1 DarkBlue +2 DarkGreen +3 DarkCyan +4 DarkRed +5 DarkMagenta +6 Brown +7 LightGray +8 DarkGray +9 Blue +10 Green +11 Cyan +12 Red +13 Magenta +14 Yellow +15 White + +When ATARI Vim starts it assumes that a default ST palette is set and maps Vim +colours to ST colours as best it can. + +The distribution includes many Vim colour schemes. Some target 256 colour +xterm displays so will not display perfectly. Tab through all colour schemes +with: + + :color + +For example, to set the blue scheme use: + + :color blue + +Remove a colour scheme using: + + :color DEFAULT + +You can check the current highlighting scheme using the :hi command. You may +wish to override some highlighting options, e.g. + + :hi Search ctermbg=0 ctermfg=15 + +:palvim (single TOS only) + +Better colour compatibility is achieved by changing the ST palette to match +Vim. A colour remapping occurs to ensure that the Vim background colour +matches the border colour. When using a resolution with fewer than 16 +colours an additional colour remapping takes place. This port supports a +maximum of 16 colours even on the TT and Falcon. + +When Vim is quit, the startup palette is restored. + +:paltos (single TOS only) + +This sets a default ST palette, potentially overriding the palette set when +Vim started. + +When Vim is quit, the startup palette is restored. + +:palmap {16 hex char string} + +You may map your existing palette to the Vim colour numbers by supplying a 16 +character hex string; one hex digit per colour indexes 0 through to 15. + +e.g. + + :palmap abc0123456789def + +will map colour index 10 to Vim colour number 0 etc + +:sane + +Will restore your palette and resolution to their startup values. + +============================================================================== + +*TOS_05* Changing Resolution *rez* + +:rez will display the current resolution. +:rez name will set the named resolution. +:rez will allow you to through all valid resolutions. +:sane will restore your palette and resolution to their startup + values. + +When Vim is quit, the startup resolution is restored. + +The current resolution is stored in the variable |v:resolution|. + +============================================================================== + +*TOS_06* Changing the Keyboard Repeat Rate *Kbrate* + +:Kbrate Display the current setting. +:Kbrate initial every Set keypresses to repeat after an initial + number of ticks and then every n 50/60Hz ticks. + +Typically, having multiple split windows open will slow down Vim. When Vim is +slow you may find it useful to alter the Kbrate, particularly the 'every' +value. Increasing it prevents the input buffer becoming too full and makes +Vim feel more responsive. + +When Vim is quit, the startup keyboard rate is restored. + +============================================================================== + +*TOS_07* Development *develop* + +Changes to the existing code are wrapped with the 'TOS' macro. + +All os_atari_* files and Make_tos.mak are specific to this port. + +============================================================================== + +vim:tw=78:ts=8:ft=help:norl:noexpandtab: +``` diff --git a/runtime_tos/compiler/vasm.vim b/runtime_tos/compiler/vasm.vim new file mode 100644 index 00000000000000..88fa4709fe3047 --- /dev/null +++ b/runtime_tos/compiler/vasm.vim @@ -0,0 +1,17 @@ +" Vim compiler file +" Compiler: vasm assembler +" Maintainer: Simon Laszcz +" Latest Revision: 2024-09-27 + +if exists("current_compiler") + finish +endif +let current_compiler = "vasm" + +let s:cpo_save = &cpo +set cpo&vim + +CompilerSet errorformat=%E%.%#error\ %n\ in\ line\ %l\ of\ \"%f\":\ %m,%Z\>%m,%-G%.%# + +let &cpo = s:cpo_save +unlet s:cpo_save diff --git a/runtime_tos/doc/os_atari.txt b/runtime_tos/doc/os_atari.txt index d49cb77e964e15..ce010dd4839c3b 100644 --- a/runtime_tos/doc/os_atari.txt +++ b/runtime_tos/doc/os_atari.txt @@ -15,7 +15,8 @@ *TOS_01* Introduction *atari* The distribution contains tiny, small and normal feature builds. The -executables are named vimt.ttp, vims.ttp and vim.ttp respectively. +executables are named vimt.ttp, vims.ttp and vim.ttp respectively. There are +also 68020-60 builds of each. vimt.ttp starts and quits much faster than vim.ttp and is also much smaller (~450Kb vs. ~1Mb) but has far fewer features (e.g. splits, command windows and @@ -23,13 +24,6 @@ eval are missing). Use the :version command to check what features a build has. -Advanced features such as tags and syntax highlighting are slow, even on -an accelerated machine. Tags are usable as long as tag files are kept -reasonably small. Syntax highlighting performance can be improved a little by -limiting the number of columns that are parsed (set synmaxcol=n). -Core features perform quite well. You might need to experiment with Vim -options to make things work. - ============================================================================== *TOS_02* Installation @@ -64,32 +58,31 @@ They could be used to conditionally set options in your vimrc. You may need to test for the availability of a feature in vimrc. Do this using has(), e.g. - if has("compiler") - compiler DEVPAC - endif - - if has("eval") - color BLUE - endif +if has("eval") + compiler DEVPAC + color BLUE +endif - if has("eval") && v:os=="TOS" - " set options, define functions. Whatever you want - endif +if has("eval") && v:os=="TOS" + " set options, define functions. Whatever you want +endif ATARI Vim looks for vimrc files in the usual places. Check where these are using the :version command. +It is recommended to store user files in $HOME\vimfiles. + ============================================================================== *TOS_03* Using a Shell *shell* *gulam* Any shell that sets the _shell_p vector can be used, e.g. Gulam. -:lmake and :lopen can be used in vim.ttp. By default Vim attempts to execute the -make utility in the current working directory. If make is not installed, the -simplest way to get this to work is to create a shell script called 'make.g'. +:lmake and :lopen can be used in vim.ttp. By default Vim attempts to execute +the make utility in the current working directory. If make is not installed, +the simplest way to get this to work is to create a shell script. -e.g. make.g might contain: +e.g. 'make.g' might contain: d:\devpac\gen.ttp main.s @@ -101,17 +94,18 @@ Then to make, use: :lmake -The cut down runtime includes compiler files for gcc and devpac. These files -will format the error output from these programs for display by :lopen. +The cut down runtime includes compiler files for gcc, devpac and vasm. These +files will format the error output from these programs for display by :lopen. For devpac you will need to set the default compiler first. Do this with the command: :compiler DEVPAC + :compiler to enumerate them ============================================================================== -*TOS_04* Setting the Palette *paltos* *palvim* *palmap* *color* +*TOS_04* Setting the Palette *paltos* *palvim* *palmap* *sane* Vim colours are numbered thus: @@ -182,13 +176,19 @@ e.g. will map colour index 10 to Vim colour number 0 etc +:sane + +Will restore your palette and resolution to their startup values. + ============================================================================== *TOS_05* Changing Resolution *rez* :rez will display the current resolution. -:rez name will set the named resolution +:rez name will set the named resolution. :rez will allow you to through all valid resolutions. +:sane will restore your palette and resolution to their startup + values. When Vim is quit, the startup resolution is restored. @@ -198,7 +198,7 @@ The current resolution is stored in the variable |v:resolution|. *TOS_06* Changing the Keyboard Repeat Rate *Kbrate* -:Kbrate Display the current setting +:Kbrate Display the current setting. :Kbrate initial every Set keypresses to repeat after an initial number of ticks and then every n 50/60Hz ticks. diff --git a/src/Make_tos.mak b/src/Make_tos.mak index 95f13420f88418..375ac5321c5908 100644 --- a/src/Make_tos.mak +++ b/src/Make_tos.mak @@ -4,7 +4,7 @@ # CC=m68k-atari-mint-gcc -AS=m68k-atari-mint-as -m68000 +AS=m68k-atari-mint-as AR=m68k-atari-mint-ar CMINI_LIB=/opt/libcmini/lib @@ -52,20 +52,62 @@ SRC = \ syntax.c \ tag.c \ term.c \ + version.c \ ui.c \ undo.c \ window.c \ os_tos.c \ os_tos_ext.c \ - os_tos_vdo.c + os_tos_vdo.c -OBJ_T=$(addprefix obj_t/, $(patsubst %.c,%.o,$(SRC))) -OBJ_S=$(addprefix obj_s/, $(patsubst %.c,%.o,$(SRC))) -OBJ_N=$(addprefix obj_n/, $(patsubst %.c,%.o,$(SRC))) +ASM_SRC = +.PHONY: lint obj clean release tags tos_utils + +INCL=vim.h globals.h option.h keymap.h macros.h ascii.h term.h os_tos.h structs.h +LIBS=-lgcc -lcmini -lgcc +# -DTOS_DEBUG - also NATFEATS for hatari conout, else create trace file +# and optionally TRACE_INPUT, TRACE_OUTPUT: trace console I/O +CFLAGS=--std=gnu99 -Os -s -Iproto \ + -nostdinc -I$(CMINI_INC) -I$(CMINI_MINT_INC) -nostdlib T_FLAGS=-DTOS -DFEAT_TINY -DFEAT_TAG_BINS S_FLAGS=-DTOS -DFEAT_SMALL -DFEAT_TAG_BINS N_FLAGS=-DTOS -DFEAT_NORMAL +M00_FLAGS=-m68000 -L$(CMINI_LIB) -DBUILD=\"68000\" +M20_FLAGS=-m68020-60 -L$(CMINI_LIB)/m68020-60/mfastcall -mfastcall -DBUILD=\"68020-60\ fastcall\" + +all: vimt.ttp vims.ttp vim.ttp vimt020.ttp vims020.ttp vim020.ttp + +# $1=ttp basename +# $2=feature build FLAGS +# $3=machine flags +define TTP_TEMPLATE +OBJ_$(1)=\ + $(addprefix obj_$(1)/, $(patsubst %.c,%.o,$(SRC))) \ + $(addprefix obj_$(1)/, $(patsubst %.s,%.o,$(ASM_SRC))) +obj_$(1): + -mkdir -p obj_$(1) + +$(1).ttp: CFLAGS += $(2) +$(1).ttp: CFLAGS += $(3) +$(1).ttp: obj_$(1) $$(OBJ_$(1)) + $(CC) $$(CFLAGS) -o $(1).ttp $$(CMINI_LIB)/crt0.o $$(OBJ_$(1)) \ + $$(LIBS) + +obj_$(1)/%.o:%.c $$(INCL) + $$(CC) -c $$(CFLAGS) -o $$@ $$< +obj_$(1)/%.o:%.s + $$(CC) -c $$(CFLAGS) -o $$@ $$< +endef + +$(eval $(call TTP_TEMPLATE,vimt,$(T_FLAGS),$(M00_FLAGS))) +$(eval $(call TTP_TEMPLATE,vims,$(S_FLAGS),$(M00_FLAGS))) +$(eval $(call TTP_TEMPLATE,vim,$(N_FLAGS),$(M00_FLAGS))) +$(eval $(call TTP_TEMPLATE,vimt020,$(T_FLAGS),$(M20_FLAGS))) +$(eval $(call TTP_TEMPLATE,vims020,$(S_FLAGS),$(M20_FLAGS))) +$(eval $(call TTP_TEMPLATE,vim020,$(N_FLAGS),$(M20_FLAGS))) + +########################################################################### RUNTIME_SRC=../runtime_tos RELROOT=tmp @@ -73,57 +115,12 @@ RELDIR=$(RELROOT)/vim TARNAME=vim74.tar.gz DOCSDIR=../runtime_tos/doc -.PHONY: lint obj clean release tags tos_utils - -# -DTOS_DEBUG - also NATFEATS for hatari conout, else create trace file -# and optionally TRACE_INPUT, TRACE_OUTPUT: trace console I/O - -INCL=vim.h globals.h option.h keymap.h macros.h ascii.h term.h os_tos.h structs.h -LIBS=-lgcc -lcmini -lgcc -CFLAGS=--std=gnu99 -Os -s -Iproto \ - -nostdinc -I$(CMINI_INC) -I$(CMINI_MINT_INC) \ - -nostdlib -L$(CMINI_LIB) - -all: vimt.ttp vims.ttp vimn.ttp - -# version.c is compiled each time, so that it sets the build time. -vimt.ttp: CFLAGS += $(T_FLAGS) -vimt.ttp: obj $(OBJ_T) version.c version.h - $(CC) $(CFLAGS) -o vimt.ttp $(CMINI_LIB)/crt0.o version.c $(OBJ_T) \ - $(LIBS) - -vims.ttp: CFLAGS += $(S_FLAGS) -vims.ttp: obj $(OBJ_S) version.c version.h - $(CC) $(CFLAGS) -o vims.ttp $(CMINI_LIB)/crt0.o version.c $(OBJ_S) \ - $(LIBS) - -vimn.ttp: CFLAGS += $(N_FLAGS) -vimn.ttp: obj $(OBJ_N) version.c version.h - $(CC) $(CFLAGS) -o vimn.ttp $(CMINI_LIB)/crt0.o version.c $(OBJ_N) \ - $(LIBS) - -obj: - -mkdir -p obj_t - -mkdir -p obj_s - -mkdir -p obj_n - -obj_t/%.o: %.c obj $(INCL) - $(CC) -c $(CFLAGS) -o $@ $< - -obj_s/%.o: %.c obj $(INCL) - $(CC) -c $(CFLAGS) -o $@ $< - -obj_n/%.o: %.c obj $(INCL) - $(CC) -c $(CFLAGS) -o $@ $< - -########################################################################### - xxd/xxd.ttp: xxd/xxd.c $(MAKE) --directory=xxd -f Make_tos.mak doctags.ttp: $(DOCSDIR)/doctags.c $(CC) $(CFLAGS) -o doctags.ttp $(CMINI_LIB)/crt0.o $(DOCSDIR)/doctags.c \ - $(LIBS) + $(M00_FLAGS) $(LIBS) tos_utils: $(MAKE) --directory=tos_utils @@ -136,15 +133,28 @@ test.tos: test.c -o test.tos $(CMINI_LIB)/crt0.o test.c \ $(LIBS) -########################################################################### +rt_doctags: + cd "$(DOCSDIR)" && \ + gcc -o doctags doctags.c && \ + echo "!_TAG_FILE_SORTED 2 " > tags && \ + ./doctags *.txt | LANG=C LC_ALL=C sort -f >> tags && \ + uniq -d -2 tags && \ + rm ./doctags + +README_TMP=README.temp +readme: + awk '/^```$$/{exit}//{print}' ../README.md > $(README_TMP) + echo '```' >> $(README_TMP) + cat ../runtime_tos/doc/os_atari.txt >> $(README_TMP) + echo '```' >> $(README_TMP) + cp $(README_TMP) ../README.md + mv $(README_TMP) ../README_tos.txt -release: clean all xxd/xxd.ttp rt_doctags doctags.ttp tos_utils +release: all xxd/xxd.ttp rt_doctags doctags.ttp tos_utils readme -rm -r $(RELDIR) -mkdir -p $(RELDIR)/rt cp -r $(RUNTIME_SRC)/* $(RELDIR)/rt - cp vimt.ttp $(RELDIR) - cp vims.ttp $(RELDIR) - cp vimn.ttp $(RELDIR)/vim.ttp + cp vim*.ttp $(RELDIR) cp xxd/xxd.ttp $(RELDIR) cp doctags.ttp $(RELDIR) cp tos_utils/tospal.tos $(RELDIR) @@ -152,15 +162,6 @@ release: clean all xxd/xxd.ttp rt_doctags doctags.ttp tos_utils cp $(RUNTIME_SRC)/doc/os_atari.txt $(RELDIR)/readme.txt cd $(RELROOT) && tar -czvf $(TARNAME) vim/ - -rt_doctags: - cd "$(DOCSDIR)" && \ - gcc -o doctags doctags.c && \ - echo "!_TAG_FILE_SORTED 2 " > tags && \ - ./doctags *.txt | LANG=C LC_ALL=C sort -f >> tags && \ - uniq -d -2 tags && \ - rm ./doctags - ########################################################################### lint: @@ -171,16 +172,11 @@ tags: ctags `find /opt/libcmini -name "*.h"` *.c *.h clean: - -rm obj_t/*.o - -rm obj_s/*.o - -rm obj_n/*.o - -rmdir obj_t - -rmdir obj_s - -rmdir obj_n + -rm -r obj_vim* -rm vim*.ttp - -rm xxd/xxd.ttp xxd/*.o - -rm tos_utils/*.o tos_utils/*.tos tos_utils/*.ttp -rm -r tmp/vim -rm doctags.ttp + $(MAKE) --directory=xxd -f Make_tos.mak clean + $(MAKE) --directory=tos_utils clean ########################################################################### diff --git a/src/ex_cmds.h b/src/ex_cmds.h index 8b5966c554c4a5..fb1b389a6443f4 100644 --- a/src/ex_cmds.h +++ b/src/ex_cmds.h @@ -778,13 +778,13 @@ EX(CMD_registers, "registers", ex_display, EX(CMD_resize, "resize", ex_resize, RANGE|NOTADR|TRLBAR|WORD1), #ifdef TOS -EX(CMD_resolution, "rez", ex_resolution, +EX(CMD_resolution, "rez", ex_resolution, WORD1|CMDWIN), -EX(CMD_palvim, "palvim", ex_palvim, +EX(CMD_palvim, "palvim", ex_palvim, WORD1|CMDWIN), -EX(CMD_paltos, "paltos", ex_paltos, +EX(CMD_paltos, "paltos", ex_paltos, WORD1|CMDWIN), -EX(CMD_palmap, "palmap", ex_palmap, +EX(CMD_palmap, "palmap", ex_palmap, WORD1|CMDWIN), #endif EX(CMD_retab, "retab", ex_retab, @@ -1142,13 +1142,17 @@ EX(CMD_rshift, ">", ex_operators, EX(CMD_at, "@", ex_at, RANGE|WHOLEFOLD|EXTRA|TRLBAR|CMDWIN), #ifdef TOS -EX(CMD_kbrate, "Kbrate", ex_kbrate, +EX(CMD_kbrate, "Kbrate", ex_kbrate, WORD1|CMDWIN), #endif EX(CMD_Next, "Next", ex_previous, EXTRA|RANGE|NOTADR|COUNT|BANG|EDITCMD|ARGOPT|TRLBAR), EX(CMD_Print, "Print", ex_print, RANGE|WHOLEFOLD|COUNT|EXFLAGS|TRLBAR|CMDWIN), +#ifdef TOS +EX(CMD_sane, "sane", ex_sane, + WORD1|CMDWIN), +#endif EX(CMD_X, "X", ex_X, TRLBAR), EX(CMD_tilde, "~", do_sub, diff --git a/src/ex_docmd.c b/src/ex_docmd.c index 73e9abead14f8e..d0190e292624f1 100644 --- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -153,6 +153,7 @@ static void ex_palvim __ARGS((exarg_T *eap)); static void ex_paltos __ARGS((exarg_T *eap)); static void ex_palmap __ARGS((exarg_T *eap)); static void ex_kbrate __ARGS((exarg_T *eap)); +static void ex_sane __ARGS((exarg_T *eap)); #endif static void ex_quit __ARGS((exarg_T *eap)); static void ex_cquit __ARGS((exarg_T *eap)); @@ -6576,6 +6577,15 @@ ex_kbrate(eap) { vdo_kbrate(eap->arg); } + + static void +ex_sane(eap) + exarg_T *eap; +{ + vdo_sane(eap->arg); + eap->arg = "DEFAULT"; + ex_colorscheme(eap); +} #endif static void diff --git a/src/os_tos.c b/src/os_tos.c index 86e256673a6583..c8d081c25db03e 100644 --- a/src/os_tos.c +++ b/src/os_tos.c @@ -135,6 +135,7 @@ static void sort_keybinding_table(struct key_binding *t); static struct { + int was_initialised; char startup_conterm; char_u *shell_cmd; const struct vdo_os *os; @@ -148,13 +149,25 @@ void mch_early_init(void) { #if defined(TOS_DEBUG) && !defined(NATFEATS) - tos_trace = fopen("C:\\TRACE.TXT", "w"); + tos_trace = fopen("TRACE.TXT", "w"); #endif + contrace(); memset(&g, 0, sizeof(g)); + vdo_early_init(); +} + +void +mch_init(void) +{ + contrace(); + g.was_initialised = TRUE; g.os = vdo_init(); Supexec(super_init); sort_keybinding_table(key_bindings_1); sort_keybinding_table(key_bindings_2); + vdo_get_default_tsize(&Rows, &Columns); + limit_screen_size(); + out_flush(); } static void @@ -200,7 +213,13 @@ void mch_exit(int r) { contrace(); - Supexec(super_restore); + + if (g.was_initialised) { + Supexec(super_restore); + /* reset the console fg/bg colour */ + OUT_STR_NF("\033c \033b/"); + } + /* ensure we exit to a fresh cmdline */ out_char('\r'); out_char('\n'); @@ -213,14 +232,6 @@ mch_exit(int r) exit(r); } -void -mch_init(void) -{ - vdo_get_default_tsize(&Rows, &Columns); - limit_screen_size(); - out_flush(); -} - int mch_get_shellsize(void) { diff --git a/src/os_tos.h b/src/os_tos.h index 1d3322bbbc7b9e..0e542a9da3b147 100644 --- a/src/os_tos.h +++ b/src/os_tos.h @@ -1,9 +1,10 @@ -/* vi:set ts=8 sts=4 sw=4: +/* vi:ts=4 sts=4 sw=4:expandtab * * VIM - Vi IMproved by Bram Moolenaar * * Do ":help uganda" in Vim to read copying and usage conditions. * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. */ /* diff --git a/src/os_tos_debug.h b/src/os_tos_debug.h index 50c4821f63bc42..2ea42bc7398685 100644 --- a/src/os_tos_debug.h +++ b/src/os_tos_debug.h @@ -1,3 +1,12 @@ +/* vi:ts=4 sts=4 sw=4:expandtab + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + #ifndef OS_TOS_DEBUG_H #define OS_TOS_DEBUG_H @@ -10,8 +19,10 @@ extern FILE *tos_trace; # define TOSPRINT(...) \ do { \ - if (tos_trace != NULL) \ + if (tos_trace != NULL) { \ fprintf(tos_trace, __VA_ARGS__); \ + fflush(tos_trace); \ + } \ } while (0); # endif diff --git a/src/os_tos_ext.h b/src/os_tos_ext.h index aea2afb6cff0f8..d37bf6af869146 100644 --- a/src/os_tos_ext.h +++ b/src/os_tos_ext.h @@ -1,4 +1,5 @@ -/* +/* vi:ts=4 sts=4 sw=4:expandtab + * * VIM - Vi IMproved by Bram Moolenaar * * Do ":help uganda" in Vim to read copying and usage conditions. diff --git a/src/os_tos_geneva.h b/src/os_tos_geneva.h index 31146146a940a2..6f42d99896a046 100644 --- a/src/os_tos_geneva.h +++ b/src/os_tos_geneva.h @@ -1,3 +1,12 @@ +/* vi:ts=4 sts=4 sw=4:expandtab + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + #ifndef OS_TOS_GENEVA_H #define OS_TOS_GENEVA_H diff --git a/src/os_tos_magic.h b/src/os_tos_magic.h index 1a5d44d8506824..e348907e6cc902 100644 --- a/src/os_tos_magic.h +++ b/src/os_tos_magic.h @@ -1,3 +1,12 @@ +/* vi:ts=4 sts=4 sw=4:expandtab + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + #ifndef OS_TOS_MAGIC_H #define OS_TOS_MAGIC_H diff --git a/src/os_tos_vdo.c b/src/os_tos_vdo.c index 5c062b71c342fc..848394c3b27333 100644 --- a/src/os_tos_vdo.c +++ b/src/os_tos_vdo.c @@ -140,6 +140,7 @@ static void restore_palette(void); static struct { + int was_initialised; short startup_kbrate; /* from cookie _VDO */ long vdo; @@ -163,21 +164,31 @@ static struct /* current rez */ struct rezdef *rezdef; int colormap[MAX_NUM_COLORS]; - int using_palvim; + enum + { + PALETTE_NONE, + PALETTE_TOS, + PALETTE_VIM + } active_palette; void *palvim; void *paltos; - int rez_changed; struct vdo_os os; /* temp buffer for strings */ char scratch[SCRATCH_BUFSZ]; } g; +void +vdo_early_init(void) +{ + memset(&g, 0, sizeof(g)); +} + const struct vdo_os * const vdo_init(void) { int rez = 0; int mode = 0; - memset(&g, 0, sizeof(g)); + g.was_initialised = TRUE; g.startup_kbrate = Kbrate(-1, -1); g.rezdef = &rezinvalid; @@ -230,6 +241,7 @@ vdo_init(void) if ((g.rezdef = match_rezdef(rez, mode)) == &rezinvalid) EMSG(_(e_rez_unknown)); init_colormap(); + (void)save_palette(); static char *os_names[] = {"TOS", "MagiC", "MiNT", "Geneva"}; g.os.magic_version = get_magic_version(); @@ -390,6 +402,9 @@ vdo_get_max_colors(void) void vdo_exit(void) { + if (!g.was_initialised) + return; + /* enable mouse relative reporting */ char kbs[] = {8}; Ikbdws(0, kbs); @@ -404,7 +419,29 @@ vdo_exit(void) g.saved_palette = NULL; g.palvim = NULL; g.paltos = NULL; - g.using_palvim = FALSE; + g.active_palette = PALETTE_NONE; +} + +void +vdo_sane(char_u *arg UNUSED) +{ + restore_resolution(); + restore_palette(); + free(g.vram); + free(g.palvim); + free(g.paltos); + g.vram = NULL; + g.palvim = NULL; + g.paltos = NULL; + g.active_palette = PALETTE_NONE; + + if ((g.rezdef = match_rezdef(g.startup_rez, g.startup_mode)) == &rezinvalid) + EMSG(_(e_rez_unknown)); +#ifdef FEAT_EVAL + set_vim_var_string(VV_RESOLUTION, g.rezdef->name, -1); +#endif + init_colormap(); + set_shellsize(g.rezdef->cols, g.rezdef->rows, TRUE); } void @@ -418,7 +455,7 @@ vdo_kbrate(char_u *arg) initial = Kbrate(-1, -1); repeat = initial & 0xFF; initial >>= 8; - snprintf(g.scratch, SCRATCH_BUFSZ, "repeat after %d ticks then every %d", initial, repeat); + snprintf(g.scratch, SCRATCH_BUFSZ, "Repeat after %d ticks then every %d", initial, repeat); g.scratch[SCRATCH_BUFSZ - 1] = NUL; MSG(g.scratch); return; @@ -495,13 +532,12 @@ vdo_resolution(char_u *arg) if (change_resolution(p->rez, p->mode) == FAIL) return; - g.rez_changed = TRUE; g.rezdef = p; #ifdef FEAT_EVAL set_vim_var_string(VV_RESOLUTION, p->name, -1); #endif set_shellsize(p->cols, p->rows, TRUE); - if (g.using_palvim) + if (g.active_palette == PALETTE_VIM) vdo_palvim(NULL); else vdo_paltos(NULL); @@ -530,9 +566,6 @@ change_resolution(int rez, int mode) static void restore_resolution(void) { - if (!g.rez_changed) - return; - if (g.vdo == VDO_FALCON) VsetScreen(g.startup_logbase, g.startup_physbase, g.startup_mode); else @@ -548,11 +581,11 @@ vdo_init_bg(void) /* may be called via init_highlight -> load_colors */ static int recursive = FALSE; - if (!g.using_palvim || recursive) + if (recursive) return; recursive = TRUE; - if (g.using_palvim) + if (g.active_palette == PALETTE_VIM) vdo_palvim(NULL); else vdo_paltos(NULL); @@ -577,7 +610,7 @@ vdo_palvim(exarg_T *eap UNUSED) if (init_palvim() == FAIL) return; - g.using_palvim = TRUE; + g.active_palette = PALETTE_VIM; init_colormap(); int bg = 0; @@ -633,7 +666,7 @@ vdo_paltos(exarg_T *eap UNUSED) return; if (init_paltos() == FAIL) return; - g.using_palvim = FALSE; + g.active_palette = PALETTE_TOS; init_colormap(); /* always change the palette */ @@ -789,7 +822,7 @@ init_colormap(void) switch (g.rezdef->num_colors) { case 16: - if (g.using_palvim) { + if (g.active_palette == PALETTE_VIM) { for (int i = 0; i < MAX_NUM_COLORS; ++i) g.colormap[i] = i; } @@ -797,7 +830,7 @@ init_colormap(void) memcpy(g.colormap, tos16, sizeof(tos16)); break; case 4: - if (g.using_palvim) + if (g.active_palette == PALETTE_VIM) memcpy(g.colormap, vim4, sizeof(vim4)); else memcpy(g.colormap, tos4, sizeof(tos4)); diff --git a/src/os_tos_vdo.h b/src/os_tos_vdo.h index 59e05e18588af4..20eead81831e2f 100644 --- a/src/os_tos_vdo.h +++ b/src/os_tos_vdo.h @@ -1,3 +1,12 @@ +/* vi:ts=4 sts=4 sw=4:expandtab + * + * VIM - Vi IMproved by Bram Moolenaar + * + * Do ":help uganda" in Vim to read copying and usage conditions. + * Do ":help credits" in Vim to see a list of people who contributed. + * See README.txt for an overview of the Vim source code. + */ + #ifndef OS_TOS_VDO_H #define OS_TOS_VDO_H @@ -9,6 +18,7 @@ struct vdo_os int is_singletos; }; +void vdo_early_init(void); const struct vdo_os * const vdo_init(void); void vdo_get_default_tsize(long *rows, long *cols); void vdo_exit(void); diff --git a/src/proto/os_tos.pro b/src/proto/os_tos.pro index 5e20c5c0ff8f60..04302f3331034f 100644 --- a/src/proto/os_tos.pro +++ b/src/proto/os_tos.pro @@ -47,6 +47,7 @@ void vdo_palvim __ARGS((exarg_T *eap)); void vdo_paltos __ARGS((exarg_T *eap)); void vdo_resolution __ARGS((char_u *arg)); void vdo_kbrate __ARGS((char_u *arg)); +void vdo_sane __ARGS((char_u *arg)); char_u *vdo_get_bg_default __ARGS((void)); int vdo_remap_colornum __ARGS((int n)); int vdo_get_max_colors __ARGS((void)); diff --git a/src/term.c b/src/term.c index e96c060ecd0f36..e100fbb104b766 100644 --- a/src/term.c +++ b/src/term.c @@ -2605,7 +2605,7 @@ out_char_nf(c) } #if defined(FEAT_TITLE) || defined(FEAT_MOUSE_TTY) || defined(FEAT_GUI) \ - || defined(FEAT_TERMRESPONSE) || defined(PROTO) + || defined(FEAT_TERMRESPONSE) || defined(PROTO) || defined(TOS) /* * A never-padding out_str. * use this whenever you don't want to run the string through tputs. diff --git a/src/version.c b/src/version.c index df6d711a6eb89b..648118f96ce554 100644 --- a/src/version.c +++ b/src/version.c @@ -1490,7 +1490,11 @@ list_version() # endif #endif #ifdef TOS +# ifdef BUILD + MSG_PUTS(_("\nATARI ST TOS (" BUILD ") version")); +# else MSG_PUTS(_("\nATARI ST TOS version")); +# endif #endif #ifdef MACOS # ifdef MACOS_X diff --git a/src/xxd/xxd.c b/src/xxd/xxd.c index 1589bf9cf7bb68..59c2a8bae973f4 100644 --- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -216,7 +216,12 @@ char osver[] = ""; /* Let's collect some prototypes */ /* CodeWarrior is really picky about missing prototypes */ static void exit_with_usage __P((void)); +#ifdef TOS +static void diex(int, int); +#define die(n) diex(__LINE__, n); +#else static void die __P((int)); +#endif static int huntype __P((FILE *, FILE *, FILE *, int, int, long)); static void xxdline __P((FILE *, char *, int)); @@ -270,6 +275,16 @@ exit_with_usage() exit(1); } +#ifdef TOS + static void +diex(ln, ret) + int ln, ret; +{ + fprintf(stderr, "died at line %d (%d)", ln, ret); + exit(ret); +} + +#else static void die(ret) int ret; @@ -278,6 +293,7 @@ die(ret) perror(NULL); exit(ret); } +#endif /* * Max. cols binary characters are decoded from the input stream per line.