⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e3-16.asm

📁 e3 是一个全屏的用户友好的文本编辑器
💻 ASM
📖 第 1 页 / 共 4 页
字号:
	clc	call SetInverseStatus%else	stosw%endif	inc bl				;counts displayed chars only	jmp DispCharLoop;-------FillLine:push cx			;continue rest of line	mov cx,[columns]		;width	sub cl,bl	mov al,SPACECHAR		;fill with blanks	jcxz FillLine2%ifdef ELKS	cmp byte[inverse],1		;special cursor attribute?%else	cmp ah,kursorfarbe%endif	jnz FillLine1%ifdef ELKS	mov al,SPACECHAR	stosB				;only 1st char with special attribute	clc	call SetInverseStatus	dec cx				;one char less	jz FillLine2FillLine1:rep stosB			;store the rest blanks%else	stosw	dec cx	jz FillLine2	mov ah,normfarbeFillLine1:rep stosw%endifFillLine2:pop cx%ifdef ELKS	mov byte[di],0%endif	call ScreenLineShow	dec cx	jz XX1	jmp DispNewLineXX1:	call RestKursPos	mov di,[fileptr]		;restore old value	ret;----------------------------------------------------------------------InitVars:mov word [textX],0a0ah		;don't touch si!	mov byte [changed],UNCHANGED	xor ax,ax	mov byte[bereitsges],al	mov [blockbegin],ax	mov [blockende],ax	mov [endedit],al	mov word[old], sot	inc ax	mov word [linenr],ax	mov byte [showblock],al	mov byte [insstat],al	mov word [error],'ER'	mov word [error+2],'RO'	mov word [error+4],'R '	mov word [error+6],'  '%ifdef ELKS	mov word [perms],PERMS%endif	cld	ret;----------------------------------------------------------------------;; STATUS LINE maintaining subroutines; at first the writer of a complete line;RestoreStatusLine:			;important e.g. for asksave	push ax	push bx	push cx	push dx	push si	push di	push bp%ifdef ELKS	mov cx,[columns]		;width	push cx	mov al,SPACECHAR		;first prepare the line buffer....	mov di,screenline	cld	rep stosb	mov al,0			;prepare ASCIIZ string	stosb	pop cx	cmp cl,stdtxtlen+15+5+2		;this window is too small	jb no_lineNr	mov bl, byte [changed]	mov byte[screenline+1],bl	;changed status	mov bx,'IN'			;Insert	cmp byte [insstat],1	jz rrr1	mov bx,'OV'			;Overwriterrr1:	mov [screenline+4],bx		;mode status	mov di,screenline+stdtxtlen	mov cx,[columns]	sub cx,stdtxtlen+15+5		;space for other than filename	mov si,filepathrrr2:	lodsb	or al,al	jz rausokay:	stosb	loop rrr2	jmp short wettraus:	mov al,SPACECHAR	stosb	loop rauswett:	mov di,screenline-15	add di,[columns]	js no_lineNr	mov ax,[columne]	inc ax				;start with 1	call IntegerToAscii	mov byte [di],':'		;delimiter ROW:COL	dec di	mov ax,[linenr]	call IntegerToAscii%else	;----------------------------------------------	mov di,zeilenangabe		;make string	mov cx,12	mov al,SPACECHAR	cld	rep stosb	mov di,zeilenangabe+8	mov ax,[columne]	inc ax				;start with 1	call IntegerToAscii	mov byte [di],':'		;delimiter ROW:COL	dec di	mov ax,[linenr]	call IntegerToAscii	cld;-------	mov cx,[columns]	mov ah,slinefarbe	mov al,SPACECHAR	mov di,screenline	cld	rep stosw	mov bl, byte [changed]	mov byte[screenline+2],bl	mov di,screenline+20	mov cx,55	mov si,filepathrrr2:   lodsb	stosw	loop rrr2	mov cx,10	mov si,zeilenangaberrr3:   lodsb	stosw	loop rrr3%endifno_lineNr:call StatusLineShow		;now write all at once	pop bp	pop di	pop si	pop dx	pop cx	pop bx	pop ax	ret;-------------------------------------------------------------------------; this function does write the line buffer to screen i.e. terminal; at begin a special entry point for writing the STATUS line below;StatusLineShow:xor cx,cx		;0 for last lineScreenLineShow:				;expecting in cx screen line counted from 0	push ax	push bx	push cx	push dx	push si	push di	push bp%ifdef ELKS%ifdef LESSWRITEOPS	xor bx,bx			;flag	mov ax,[columns]	add ax,32			;estimated max ESC sequences extra bytes (i.e. boldlen*X)	mul cl	mov di,screenbuffer	add di,ax	cld;	xor dx,dx			;counter	mov si,screenlinesl_3:	lodsb;	inc dx				;count message length to write	cmp di,screenbuffer_end		;never read/write beyond buffer	jnb sl5	cmp al,[di]	jz sl4	mov [di],alsl5:	inc bx				;set flag whether line need redrawingsl4:	inc di	or al,al	jnz sl_3	or bx,bx			;redraw ?	jz NoWrite%endif	mov dh,byte [lines]	sub dh,cl	mov dl,0	call sys_writeKP	call sys_writeSL	mov dx,[kurspos2]	call sys_writeKP		;restore cursor pos%else%ifdef DO_NOT_USE_AX_1302		;very slow (but running on some very old 1980's PC)	mov si,screenline	cld	mov dh,[lines]	sub dh,cl	mov dl,0no1302:	call sys_writeKP	lodsw	mov bl,ah	mov bh,0	mov ah,09h	mov cx,1	int 10h	mov al,[columns]	dec al	cmp dl,al	inc dl	jb no1302	mov dx,[kurspos2]	call sys_writeKP		;restore cursor pos%else	mov ax,1302h	mov bx,0	mov dh,[lines]	sub dh,cl	mov dl,0	mov cx,[columns]	mov bp,screenline	int 10h%endif%endifNoWrite:	pop bp	pop di	pop si	pop dx	pop cx	pop bx	pop ax	ret;-----------------------------------------------------------------------; write an answer prompt into status line; (with and without re-initialisation); expecting dx points to ASCIIZ-string;WriteMess9MachRand:	call InitStatusLineWriteMess9:%ifdef ELKS	push ax	push bx	push cx	push dx	push si	push di	push bp	mov di,screenline	mov si,dx	cldWriteMLoop:lodsb	or al,al	jz WriteMEnd	cmp al,0ah			;for error messages	jz WriteMEnd	stosb	jmp short WriteMLoopWriteMEnd:call StatusLineShow	pop bp	pop di	pop si	pop dx	pop cx	pop bx	pop ax%else	;---------------------	push si	push di	mov si,dx	cld	mov di,screenline	mov ah,slinefarbeWriteMLoop:lodsb	or al,al	jz WriteMEnd	cmp al,0dh	jz WriteMEnd	stosw 	jmp short WriteMLoopWriteMEnd:call StatusLineShow	pop di	pop si%endif	call KursorStatusLine	ret;-------; another way: write 2 letters in ch/cl to status line; called by MakeScanCode for showing ^K and ^Q status (lower left);WriteTwo:push di%ifdef ELKS	mov word[screenline],cx%else	mov di,screenline	mov al,cl	mov ah,slinefarbe	cld	stosw	mov al,ch	stosw%endif	call StatusLineShow		;write the line on last screen line	pop di	ret;--------------------------------------------------------------------; a helper for other status line functions:; simply init an empty line  ;InitStatusLine:push di	push ax	push cx	mov di,screenline	cld	mov al,SPACECHAR	mov cx,[columns]%ifdef ELKS	cld	rep stosb%else	mov ah,slinefarbe	rep stosw%endif	pop cx	pop ax	pop di	ret;-----------------------------------------------------------------------;; getting INPUT from terminal; at first read a whole string until <enter> pressed,; follwed by handling reading one char alone;%ifdef ELKS; expecting buffer in cx; expecting count byte in dxInputString:call sys_writeSLColors1				push cx	mov bx,stdin			;file desc	call ReadFile	pop cx			stc	js ISRet	dec ax				;0ah	push bx	mov bx,ax	add bx,cx	mov byte[bx],0			;make asciz string	pop bx	cmp ax,1			;set cy flag if empty stringISRet:	pushf	call sys_writeSLColors0		;FIXME should flush stdin: read until empty buffer	popf			ret%else	;----------------------------------InputString:mov dx,cx			;ELKS register style	xor cx,cx			;char counter 	push di	mov di,dx	cldGetNameLoop:call GetChar	cmp ah,4bh			;left	jz GetNameDelete	cmp ah,4dh	jz GetNameOldChar	or al,al	jz GetNameLoop	cmp al,7	jz GetNameLoop			;no beep	cmp al,0dh	jz GetNameEnd	cmp al,1bh	stc	jz GetNameErr	cmp al,8	jnz GetNameCharGetNameDelete:mov al,8	dec cx	jS GetNameNoToDel	call xDispChar	dec di	mov al,0	call xDispChar	mov al,8	call xDispChar	jmp short GetNameLoopGetNameOldChar:mov al,[di]	or al,al	jz GetNameLoopGetNameChar:stosb	call xDispCharGetNameNoToDel:inc cx	cmp cl,maxfilenamelen	jnc GetNameEnd	jmp short GetNameLoopGetNameEnd:mov byte [di],0	mov ax,di	sub ax,dx			;ret ax=lge	cmp ax,1			;clcGetNameErr:pop di	ret;-------xDispChar:push bx			;char in al	mov ah,0eh	mov bx,0111b			;page bh,0	int 10h	pop bx	ret%endif;-----------------------------------------------------------------------%ifdef ELKS;; GetChar returns ZERO flag for non ASCII (checked in HandleChar); FIXME: e3-32 bit does the IOctlTerminal only at start/end of editor...; ...but here we are calling IOctlTerminal each time (==useless overhead); (see diff e3 release 0.1 -> 0.2);ReadChar:mov ax,di	xchg ax,[old] ;fuer ^QP	mov [veryold],axGetChar:mov cx, 0x5401			;TCGETS asm/ioctls.h	mov dx,termios	call IOctlTerminal	call SaveTermStruc	push bx	mov bx,dx	and byte [bx+12],(~2 & ~1 & ~8)	;icanon off, isig (^C) off, echo off	and byte [bx+ 1],(~4)		;ixon off	was:and word [bx+ 0],(~400h)	pop bx	mov cx, 0x5402			;TCSETS asm/ioctls.h	call IOctlTerminal		;dx is termios pointerreadloop:call ReadOneChar	cmp al,7FH	jne No7F			; special case: remap DEL to Ctrl-H	mov al,8No7F:	cmp al,27 			; ESC ?	jnz ready_2	call ReadOneChar		;e.g.  [ for ELKS vt100	mov bl,48h			;48h up - the lowest	cmp al,'A'	jz ready	add bl,3			;4Bh left	cmp al,'D'			jz ready	add bl,2			;4Dh right	cmp al,'C'	jz ready	add bl,3			;50h down	cmp al,'B'	jz ready	jmp short ready_2;-------ready:	xor ax,ax	mov ah,blready_2:push ax	mov cx,0x5402			;TCSETS asm/ioctls.h	mov dx,orig	call IOctlTerminal		; restore termios settings	pop ax	or al,al			; was similar DOS version (via BIOS int 16h)	ret;-------SaveTermStruc:push di	mov si,termios	mov di,orig	mov cx,termios_size	cld	rep movsb	pop di	ret;-------; called by ReadChar/GetChar;ReadOneChar:mov bx,stdin		;file desc	mov cx,read_b 			;pointer to buf	xor dx,dx	inc dx				;mov dx,1  (length)	call ReadFile	mov ax,[read_b]	ret%else   ;-------ReadChar:mov ax,di	xchg ax,[old]			;for ^QP	mov [veryold],ax	call GetChar	or al,al	ret;-------GetChar:mov ah,0	int 16h	ret%endif;----------------------------------------------------------------------%ifdef ELKS;; helper subroutine called by DispNewScreen;SetInverseStatus:	push si				; returns zero flag	push cx	mov cx,boldlen	jnc SIS1	cmp byte [insstat],1	stc	jnz SIS4	mov byte[inverse],1	mov si,reversevideoX	rep movsb	jmp short SIS3SIS1:	cmp byte[inverse],1	jnz SIS3	mov byte[inverse],0	mov byte[isbold],0SIS_5:	mov si,bold0	rep movsbSIS3:	clcSIS4:	pop cx	pop si	ret%endif;-------; another helper subroutine called by DispNewScreen;SetColor:%ifdef ELKS	call IsShowBlock	push si				;expects cy flag:bold /  nc:normal	push cx	mov cx,boldlen	jnc SFEsc1	cmp byte [isbold],1		;never set bold if it is already bold	jz SFEsc2SCEsc_2:mov si,bold1	rep movsb	mov byte [isbold],1	jmp short SFEsc2SFEsc1:	cmp byte [isbold],0		;ditto	jz SFEsc2	mov si,bold0	rep movsb	mov byte [isbold],0SFEsc2:	pop cx	pop si	ret%ifdef LESSWRITEOPSSetColor2:push si	push cx	call IsShowBlock	mov cx,boldlen	jnc SIS_5	jmp short SCEsc_2%endif%else	;---------------------------------	mov ah,normfarbe	cmp byte[showblock],0	je SetColorEnde	cmp word [blockbegin],0	je SetColorEnde	cmp [blockbegin],si	ja SetColorEnde	cmp si,[blockende]	jnb SetColorEnde	mov ah,blockfarbeSetColorEnde:ret%endif;-----------------------------------------------------------------------;; LOWER LEVEL screen acces function (main +2 helpers)   (ELKS only);%ifdef ELKSsys_writeSL:push cx	or cx,cx	jnz sl1	call sys_writeSLColors1		;special for status line (cx==0)sl1:    push si	cld	xor dx,dx	mov si,screenlinesl3:	lodsb	inc dx				;count message length to write	or al,al	jnz sl3	dec dx				;one too much	pop si	mov bx,stdout			;first argument: file desc (stdout)	mov cx,screenline		;second argument: pointer to message to write	call WriteFile	pop cx	or cx,cx	jnz sl2	call sys_writeSLColors0sl2:	ret;-------sys_writeSLColors1:	push ax	push bx	push cx	push dx	push si	push di	push bp	mov cx,screencolors1		;set bold yellow on blue	jmp short SwSL;-------sys_writeSLColors0:	push ax	push bx	push cx	push dx	push si	push di	push bp	mov cx,screencolors0		;reset to b/wSwSL:	mov bx,stdout	mov dx,scolorslen	call WriteFile	pop bp	pop di	pop si	pop dx	pop cx	pop bx	pop ax	ret	       %endif;----------------------------------------------------------------------;; L O O K functions; search special text locations and set register di

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -