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

📄 e3.asm

📁 e3 是一个全屏的用户友好的文本编辑器
💻 ASM
📖 第 1 页 / 共 5 页
字号:
	call IsClipboardFormatAvailable	or eax,eax	jz KECY0	push byte CF_OEMTEXT	call GetClipboardData	or eax,eax	jz KECY0	mov edi,ebp	inc edi				;one after eof	mov ecx,[maxlen]	add ecx,sot			;the last possible byte	xor ebx,ebx	dec ebx				;init counter -1	xchg esi,eax	cldKloop:	lodsb	inc ebx	cmp edi,ecx	jnb KECY2	stosb	or al,al	jnz KloopKECY2:  mov [EmaKiSize],ebx	KECY0:	call CloseClipboardKECY3:	popaKECY:%endif	mov ecx,[EmaKiSize]	jecxz KeawRet	xchg eax,ecx			;OLD mov eax,ecx 1 byte longer	push eax	call InsertByte	pop ecx	jc KeawRet			;no_space_error is handled in InsertByte	mov esi,ebp	inc esi	mov [EmaMark],edi	cld	rep movsb	call ShowBl0			;i.e. "mov byte [showblock],0"	call IsViMode	jz ISVI9	call KeyEmaCtrlLISVI9:	jmp CQFNum;-------KeyEmaAltW2:pusha	mov edi,ebp	inc edi	call IsViMode	jz KEW;-------	cmp byte [EmaCtrlK],1	jnz KEW	add edi,[EmaKiSize]	add [EmaKiSize],eax	jmp short KE2KEW:	mov [EmaKiSize],eax	mov [EmaKiSrc],esiKE2:	mov ecx,eax	cld	rep movsb	call ShowBl0			;i.e. "mov byte [showblock],0"Keaw2:	mov byte [EmaCtrlK],1	popaKeawRet:ret;-------KeyEmaAltW:mov byte [VInolinebased],0	pusha	mov ecx,[showblock]	jecxz Keaw2	mov ecx,[EmaMark]	jecxz Keaw2	mov eax,edi	cmp ecx,eax	jb KEAW	xchg eax,ecxKEAW:	sub eax,ecx			;eax end / ecx beg	mov esi,ecx	mov edi,ebp	inc edi	mov [EmaKiSize],eax	mov [EmaKiSrc],esi	xchg eax,ecx			;OLD mov ecx,eax 1 byte longer	cld	rep movsb	call IsViMode	jz KEAW3	call ShowBl0			;i.e. "mov byte [showblock],0"KEAW3:	%ifdef W32	cmp byte[mode],NE		;Nedit ^C	jnz KEAW4	push dword [EmaKiSize]	push byte 0	push dword [heap]	call HeapAlloc	or eax,eax	jz KEAW4	mov esi,[EmaKiSrc]	mov edi,eax	mov ecx,[EmaKiSize]	cld	rep movsb	mov byte[edi],0			;ASCIIZ;-------	push dword [heap]	push byte 0	push eax			;push for later usage in HeapFree	push eax			;push clip handle for SetClipboardData	push byte 0	call OpenClipboard	or eax,eax	jz KEAW8	call EmptyClipboard	push byte CF_OEMTEXT	call SetClipboardData	call CloseClipboardKEAW8:	call HeapFreeKEAW4:%endif	popaKeaWRet:ret;----------------------------------------------------------------------;; functions reading/writing  text or blocks  from/into  files;NFnoarg:mov esi,helptext		;initial part of help	mov edi,sot	push byte helptextsize	pop ecx	push edi	rep movsb;-------	call GetHelpText		;second part of help	lea ebp,[ecx+sot+helptextsize]	;set END_OF_HELP_TEXT pointer	rep movsb	pop edi	call DispNewScreen;-------	mov esi, filename	mov ecx, filepath	call InputString0	jnc GetFile			;empty string not allowed here	ret;-------KeyVICmdE:lea esi,[ecx+2]	cmp byte [esi],SPACECHAR	je KeaWRet	pusha				;save before load new	call SaveFile	popa;-------continueNewFile:cld	call InitVars	or esi,esi	jz NFnoarg	mov edi,filepathNF1:%ifdef W32	lodsb	cmp al,'"'	jz NF1	stosb	cmp al,SPACECHAR		;truncate after blanks	jnz NF3NF4:	mov byte [edi-1],0	jmp short GetFileNF3:	cmp al,TABCHAR	jz NF4	%else	lodsb	stosb%endifNF2:	or al,al	jnz NF1;------- contGetFile:%ifdef BEOS	xor ebx,ebx	mov edx,ebx	dec ebx				;edx==0,ebx==-1	mov ecx,filepath%else	mov ebx,filepath%endif	call OpenFile0	mov edi,sot	mov ebp,edi	js NewFileEnd%ifdef SYS_brk	call Seek	pusha	lea ebx,[eax+eax+102400]	;twice filesize plus reserve = space for inserts	mov [maxlen],ebx	add ebx,text	call SysBrk	popa	js OSejmp1			;OSerror%else	mov ebx,eax			;for FreeBSD memory is hard coded by maxlen%endif;-------%ifdef SYS_fstat			;not for W32,BEOS	call Fstat	js OSejmp1			;OSerror	mov eax,[fstatbuf+stat_struc.st_mode]%ifdef FREEBSD	mov ecx,eax	and ecx,0F000h			;see /usr/include/sys/stat.h	cmp ecx,8000h			;not for special files	jz regFile	push byte ERRNOREGFILE	pop dword [ErrNr]	jmp OSerrorregFile:%endif		and eax,777q	mov [perms],eax%ifdef SYS_utime		mov eax,[fstatbuf+stat_struc.st_mtime]	mov [accesstime+utimbuf_struc.modtime],eax%endif%endif					;end of code not for W32,BEOS;-------OldFile1:mov edx,[maxlen]		;i.e. either 'max' or filesize twice	mov ecx,edi			;sot	call Read_File	xchg edx,eax			;mov edx,eax	bytes read	js OSejmp0			;OSerror	call CloseFileOSejmp1:js OSejmp0			;OSerror	lea ebp,[edx+sot]		;eof_ptr=filesize+start_of_textNewFileEnd:mov byte [ebp],NEWLINE	;eof-marker	clcNFEnd2:	ret;-------;  save file (called by ^KS,^KX);SaveFile:cmp byte [changed],UNCHANGED	jz NFEnd2			;no changes: nothing to save	mov esi, filesave	call WriteMess9;-------	mov esi,filepath	push edi	mov edi,bakpath	mov ebx,esi	mov ecx,edi	cldSF0:	lodsb	stosb				;copy to BAK file path	or al,al	jne SF0	dec edi	push byte '~'			;add BAK file extension	pop eax%ifdef ARMCPU	stosb	shr eax,8	stosb		shr eax,8	stosb	shr eax,8	stosb%else	stosd				;not stosb because ascii-ZERO%endif	pop edi%ifdef BEOS	push edi	mov ebx,0xFFFFFFFF	mov edx,ebx	mov ecx,filepath	mov edi,bakpath%endif%ifdef MAKE_BACKUP	cmp dword [ecx],'/tmp'	je no_ren%ifdef SYS_readlink	pusha	mov ecx,linkbuffer		;we are only interested whether symlink or not	push byte linkbuffersize	;=4 byte dummy buffer	pop edx	call ReadLink	popa	jns CopyBAK			;no error means it's a symlink...	call RenameFile                 ;...but plain files are easy to rename (ecx is filepath)	jmp short no_ren		;...simlilar behave 'xemacs' and 'jed'CopyBAK:call CopyToBackup		;we can't simply rename the link%else	call RenameFile                 ;ecx is filepath%endifno_ren:	;...continue here...%endif%ifdef BEOS	pop edi%endif;-------%ifdef W32	mov ecx,CREATE_ALWAYS	mov ebx,filepath	mov edx,GENERIC_WRITE%else%ifdef BEOS	mov ebx,0xFFFFFFFF	mov ecx,filepath	mov edx,0x777%else	mov ecx,O_WRONLY_CREAT_TRUNC	mov edx,[perms]%endif%endif	call OpenFileOSejmp0:js OSejmp9			;OSerror	xchg ebx,eax			;file descriptor  (xchg is only 1 byte);-------%ifdef SYS_fstat	mov ecx,[fstatbuf+stat_struc.st_uid]%ifdef UIDGID_WORD			;Linux special	mov edx,ecx	shr edx,16	movzx ecx,cx			;OLD and ecx,0xffff%else	mov edx,[fstatbuf+stat_struc.st_gid]%endif	call ChownFile%endif;-------	mov ecx,sot			;ecx=bof	mov edx,ebp			;eofSaveFile2:sub edx,ecx			;edx=fileesize= eof-bof	call IsViMode	jnz NoAddNL	cmp byte [ebp-1],NEWLINE	jz NoAddNL	inc edx				;append NewLine char for VI modeNoAddNL:call Write_File			;ebx=file descriptorOSejmp9:js OSejmp			;OSerror	push byte ERRNOIO	pop dword[ErrNr]		;just in case of....	cmp eax,edx			;all written?%ifdef BEOS	jnz near OSerror%else	jnz OSerror%endif	call CloseFile	js OSejmp			;OSerrorSaveFile3:ret;-------;  save block (called by ^KW);SaveBlock:call GetBlockName	jc jcDE2SaveBl2:%ifdef W32	mov ebx,blockpathSaveBl3:mov ecx,CREATE_ALWAYS	mov edx,GENERIC_WRITE%else%ifdef BEOS	mov ebx,blockpathSaveBl3:mov ecx,0xFFFFFFFF	xchg ebx,ecx	mov edx,0x241			;was 0x777 upto Dec 01%else	mov ebx,blockpathSaveBl3:mov ecx,O_WRONLY_CREAT_TRUNC	mov edx,PERMS%endif%endif	call OpenFile	js OSejmp			;OSerror	mov ecx,esi			;= block begin	mov edx,[blockende]	xchg ebx,eax			;file descriptor  (xchg is only 1 byte)	jmp short SaveFile2;-------; read a block into buffer (by ^KR);ReadBlock:call GetBlockNamejcDE2:	jc near DE2ReadBlock2:%ifdef BEOS	xor ebx,ebx	mov edx,ebx	dec ebx				;edx==0,ebx==-1	mov ecx,blockpath%else	mov ebx,blockpath%endif	call OpenFile0OSejmp:	js OSerror	call Seek	js OSerror	push eax			;eax=fileesize	call InsertByte	pop edx				;file size	jc SaveFile3			;ret if cy InsertByte told an error message itself	mov ecx,edi			;^offset akt ptr	call Read_File	js preOSerror			;to delete inserted bytes (# in EDX)	mov ecx,eax    			;bytes read	call CloseFile	js OSerror	push byte ERRNOIO	pop dword[ErrNr]		;just in case of....	cmp edx,ecx			;all read?	jnz OSerror	ret;-------preOSerror:mov eax,edx			;count bytes	call DeleteByte			;delete space reserved for insertationOSerror:push edi	mov edi,error+8			;where to store ASCII value of ErrNr	mov eax,[ErrNr]	push eax	call IntegerToAscii	pop ecx				;for getting error text via LookPD2	cmp ecx,MAXERRNO	ja DE0	mov edi,errmsgs	call LookPD2			;look message # (ecx) in line number #	mov esi,edi	mov edi,error+9	mov ax,' :'%ifdef ARMCPU	stosb				;error+9 is not aligned%else	stosw%endif	push byte 80			;max strlen / compare errlen equ 100	pop ecx	rep movsbDE0:	mov esi,error	pop ediDE1:	call WriteMess9	call ReadOneChar		;was GetCharDE2:	;continued...;----------------------------------------------------------------------;; more STATUS LINE maintaining subroutines;RestoreStatusLine:pusha			;important e.g. for asksave	call InitStatusLine	mov esi,mode	mov ecx,[columns]		;width	cmp cl,stdtxtlen+15+5+2		;this window is too small%ifdef ARMCPU	and ecx,0xFFFFFFFC		;get aligned%endif	jb near RSno_lineNr	mov al,byte[changed]	mov byte[screenline+1],al	;changed status;-------%ifndef LINUX	lea eax,[ecx-13+screenline]	;FreeBSD or Beos ...%else	lea eax,[ecx-12+screenline]%endif	mov word[eax+8],'vi'		;vi does show mode info only.	cmp byte [esi],VI		;vi doesn't get altH text because altH won't work...	jnz RSL0			;...caused by different handling due single ESC keys	cmp byte [VICmdMode],1	jnz NOVI0	mov ebx,'CMD '	jmp short RSL1RSL0:	mov dword [eax],'altH'	mov dword [eax+4],'=hel'	;'p' is stored with editor mode name	mov ebx,editmode	mov edx,[ebx]	cmp byte [esi],PI	jnz No_PI1	mov edx,[ebx+4]No_PI1:	cmp byte [esi],EM	jnz No_Em1	mov edx,[ebx+8]No_Em1:	cmp byte [esi],NE	jnz No_Ne1	mov edx,[ebx+12]No_Ne1:	mov [eax+8],edx;-------NOVI0:	mov ebx,'INS '			;Insert	cmp byte [insstat],1	jz RSL1	mov ebx,'OVR '			;OverwriteRSL1:	mov [screenline+4],ebx		;mode status	mov edi,screenline+stdtxtlen	lea ecx,[ecx-(stdtxtlen+15+5)]	;space for other than filename	mov esi,filepath		;lea ... is shorter than sub ecx,stdtxtlen+15+5RSL2:	lodsb	or al,al	jz RSL4	stosb	loop RSL2RSL4:	mov edi,screenline-15	add edi,[columns]	mov eax,[columne]	inc eax				;start with 1	call IntegerToAscii	mov byte [edi],':'		;delimiter ROW:COL	dec edi	mov eax,[linenr]	call IntegerToAsciiRSno_lineNr:call StatusLineShow		;now write all at once	popa	stc				;error status only important if called via OSError	ret;-------;; write an answer prompt into status line; (with and without re-initialisation); expecting esi points to ASCIIZ or 0A terminated string;WriteMess9MakeLine:call InitStatusLineWriteMess9:pusha	mov edi,screenline	cldWriteMLoop:lodsb	cmp al,LINEFEED			;for error messages	jbe WriteMEnd	stosb	jmp short WriteMLoopWriteMEnd:call StatusLineShow	popa	jmp KursorStatusLine;-------; a helper for other status line functions:; simply init an empty line;InitStatusLine:pusha			;simply init an empty line	mov edi,screenline	mov al,SPACECHAR	mov ecx,[columns]%ifndef LINUX	dec ecx				;? FreeBSD	js ISL				;should never be = -1%endif	cld	rep stosb	mov al,0			;prepare ASCIIZ string	stosbISL:	popa	ret;-------; read a file name for block operations;GetBlockName:pusha	mov esi,block	mov ecx,blockpath	call InputString0		;cy if empty string	pushf	call RestKursPos	popf	popa	ret;-------; helper for NewFile;InitVars:mov byte [text],NEWLINE	;don't touch esi!	call Unchg			;i.e. "mov byte [changed],UNCHANGED"	call InitSomeVars		;set eax=0	mov dword[old],sot	inc eax				;set eax=1	mov byte [VICmdMode],al	mov dword [linenr],eax	mov byte [insstat],al	mov dword [maxlen],max	mov dword [error],'ERRO'	mov dword [error+4],'R   '	mov dword [perms],PERMS%ifdef SYS_fstat	dec eax	dec eax				;eax == -1 i.e. no changes in fchown%ifdef UIDGID_WORD			;Linux special	mov [fstatbuf+stat_struc.st_uid],eax	;both: giduid%else	mov [fstatbuf+stat_struc.st_gid],eax	mov [fstatbuf+stat_struc.st_uid],eax%endif%endif	jmp ShowBl1			;i.e. mov byte [showblock],1;-------InitSomeVars:	xor eax,eax%ifdef USE_UNDO	mov [undobuffer],eax		;i.e. invalid pointer 	mov dword[undoptr],undobuffer+4 ;init to first frame%endif	mov [EmaMark],eax	mov dword [oldQFpos],eax	mov byte[bereitsges],al	mov [endeedit],alInitSV1:mov [EmaKiSize],eax		;do not allow side effectsInitSV2:mov [blockbegin],eax		;i.e. 

⌨️ 快捷键说明

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