?? wordedit.asm
字號:
red_chr macro ;從鍵盤讀取字符宏定義
mov ah,0 ;AL=字符碼(即ASCII碼),AH=掃描碼
int 16h
endm
string macro p1
;顯示字符串宏定義
mov ah,9
lea dx,p1
int 21h
endm
win macro opr1,opr2,opr3,opr4,opr5,opr6 ;屏幕初始化
mov ah,06h ;6號功能
mov al,opr1 ;下卷行數(shù),AL=0時,整個窗口空白
mov bh,opr2 ;卷入行屬性
mov ch,opr3 ;左上角行號
mov cl,opr4 ;左上角列號
mov dh,opr5 ;右下角行號
mov dl,opr6 ;右下角列號
int 10h
endm
pos_curse macro op1,op2,op3 ;置光標位置
mov ah,2
mov bh,op1 ;頁號
mov dh,op2 ;行號
mov dl,op3 ;列號
int 10h
endm
pos_get macro ;讀光標位置
mov ah,03h
mov bh,0
int 10h
endm
;---------------------數(shù)據(jù)段-----------------------------------------
data segment ;定義數(shù)據(jù)段
;-------------屏幕顯示內容-----------------------------------
menu db 'File Edit Help $'
mass_1 db 'F1 Active file F10 Active help','$'
manu_1 db ' New ',13,10,'$'
manu_2 db ' Open ',13,10,'$'
manu_3 db ' Save ',13,10,'$'
manu_4 db ' Save as.. ',13,10,'$'
manu_5 db ' Exit ','$'
handle dw ?
message1 db ' Please input file name:','$'
message2 db ' Please input save file name:','$'
message3 db ' Please input open file name:','$'
message4 db ' ***The file is not save! Save it now? (Y/N)***: ','$'
message5 db ' Please input save file path:','$'
message6 db ' Sorry!No this file.','$'
path db 50 dup(0),'$'
buffer db 2000 dup(?)
bak db 3850 dup(0)
line db ? ;存放光標列
row db ? ;存放光標行
char db ?
tempLine db ?
addr dw ?
cur dw ?
;-------------幫助內容-----------------------------
help_mas1 db ' Thanks for use our wordedit! $'
help_mas2 db 'please the first active help! $'
help_mas3 db 'Good lucky!! $'
help_mas4 db '==========================================================$'
help_mas5 db 'You can Press F1 to active file. $'
help_mas6 db 'Then use DOWN cursor key to choose the fuction $'
help_mas7 db 'Press F10 to show the help massage.$'
date db 'today ??/??/','$' ;設置日期
hanglie db '???//???','$' ;設置行列
data ends
;---------------------代碼段--------------------------------------
code segment
main proc far ;主程序
assume cs:code,ds:data
start:
push ds
sub ax,ax
push ax
mov ax,data
mov ds,ax
call wind
call edit
ret
main endp
;------------------創(chuàng)建窗口子程序--------------------------
wind proc near
push ax
push bx
push cx
push dx
win 0,1fh,1,0,24,79 ;設置文本輸入背景色和輸入字符顏色(藍底白字)
win 1,70h,0,0,0,79 ;設置菜單欄背景色和顯示字符顏色 (灰底黑字)
win 0,70h,24,0,24,79 ;設置狀態(tài)欄背景色和顯示字符顏色 (灰底黑字)
show:
pos_curse 0,0,1
mov ah,9
lea dx,menu ;顯示菜單欄內容
int 21h
show_2:
pos_curse 0,24,1
mov ah,9
lea dx,mass_1
int 21h ;顯示狀態(tài)欄內容
call win3 ;win3顯示日期
mov dh,1 ;初始化光標位置和光標位置的顯示
mov dl,0
call win4
pos_curse 0,1,0
mov row,dh
mov line,dl
pop dx
pop cx
pop bx
pop ax
wind endp
;----------------編輯功能設定---------------------------------
edit proc near
char_get: ;讀字符
call com
;---------------------定義功能鍵----------------------
com proc near
pos_get
mov row,dh
mov line,dl
call win4
first:
pos_curse 0,row,line
j00: mov ah,0
int 16h ;從鍵盤讀字符 ah=掃描碼 al=字符碼
push ax
cmp al,0
je chars
lea dx,buffer
mov buffer[bx],al
inc bx
chars: cmp ah,48h ;光標上移
jz up_1
cmp ah,50h ;光標下移
jz down_1
cmp ah,4bh ;光標左移
jz left
cmp ah,4dh ;光標右移
jz right
cmp ah,1ch ;回車
jz enter_1
call fuc_key ;功能鍵HOME,END,BACKSPACE,F10(HELP)調用
mov ah,2
mov dl,al
int 21h
pop ax
call menu_show ;查看是否為F1鍵
jmp j6
down_1:
jmp down
enter_1:
jmp enter_2
up_1:
jmp up
left: ;光標左移
pos_get
mov row,dh
mov line,dl
cmp line,0
jnz direct
cmp row,1
je first
mov line,79
dec row
mov dh,row
mov dl,line
call win4
jmp first
stop2:
mov row,1
jmp first
direct:
dec line
mov dl,line
call win4 ;狀態(tài)欄中顯示光標位置
jmp first
right: ;光標右移
pos_get
mov row,dh
mov line,dl
cmp line,79
jnz direct2
cmp row,23
je first1
mov line,0
inc row
mov dh,row
mov dl,line
call win4
jmp first
first1:
jmp first
direct2:
inc line
mov dl,line
call win4
jmp first
enter_2:
jmp enter
up: ;上移光標
pos_get
mov row,dh
mov line,dl
cmp row,1
je first1
dec row
mov dh,row
call win4
jmp first
down: ;下移光標
pos_get
mov row,dh
mov line,dl
cmp row,23
je first1
inc row
mov dh,row
call win4
jmp first
enter: ;回車換行
pos_get
mov row,dh
mov line,dl
cmp row,23
je returns
inc row
mov line,0
mov dh,row
mov dl,0
call win4
jmp first
returns:
mov line,0
mov dl,0
call win4
jmp first
j6:
jmp first
com endp
;-----------------功能鍵子程序-------------------------
fuc_key proc near
next:
cmp ah,47h ;home
jz home
cmp ah,4fh ;end
jz _end
cmp ah,0eh ;backspace
jz bak_sp
cmp ah,53h
jz del1
cmp ah,44h ;F10,顯示幫助信息
jz help_0
ret
help_0: call help
home: ;HOME鍵的功能
pos_get
mov row,dh
mov line,0
mov dl,0
call win4
jmp first
del1: jmp del
_end: ;END鍵的功能
pos_get
mov row,dh
mov line,79
mov dl,79
call win4
jmp first
bak_sp: ;退格鍵的功能
pos_get
mov row,dh
mov line,dl
cmp line,0
je back_up
dec line
mov dl,line
call win4
jmp ab
back_up:
cmp row,1
je ab
mov line,79
dec row
mov dh,row
mov dl,line
call win4
jmp ab
ab:
pos_curse 0,row,line
mov ah,2
mov dl,00
int 21h
jmp first
del: ;DEL刪除
pos_get
mov row,dh
mov line,dl
dec line
pos_get
mov ah,2
mov dl,00
int 21h
inc line
call win4
jmp first
cm:
cmp line,00
jz pos_cm
pos_cm:
pos_curse 0,0,0
jmp first
help proc near ;顯示幫助信息
call savedisplay
push ax
push bx
pos_get ;顯示幫助信息每行的位置
push dx
win 0,57h,4,5,21,70
pos_curse 0,6,25
string help_mas1
pos_curse 0,8,11
string help_mas2
pos_curse 0,10,11
string help_mas3
pos_curse 0,12,11
string help_mas4
pos_curse 0,14,11
string help_mas5
pos_curse 0,16,11
string help_mas6
pos_curse 0,18,11
string help_mas7
pop dx
pos_curse 0,dh,dl
mov ah,0
int 16h
cmp ah,36h ;F10 active help
jnz cls
call help
cls:
win 0,1eh,9,10,13,70 ;清屏
call backdisplay
pop bx
pop ax
help endp
;-------------顯示菜單---------------------------------------
fuc_key endp
menu_show proc near
call savedisplay
push bx
;push cx
cmp ah,3bh ;F1功能
jz menu_sh
jmp char_get
menu_sh: ;定義菜單的背景字體顏色
pos_get
push dx
win 0,07h,2,1,7,11
win 0,70h,1,0,6,10
pos_curse 0,1,0
string manu_1
string manu_2
string manu_3
string manu_4
string manu_5
pop dx
dec dl
pos_curse 0,dh,dl
copmar:
red_chr
cmp ah,50h ;50h為向下箭頭的掃描碼
jz manu_n
jmp manu_hid
manu_hid: ;菜單隱藏
win 0,1eh,1,1,7,11
call backdisplay
pop bx
jmp char_get
manu_e0:
win 0,70h,1,0,1,10
pos_curse 0,1,0
string manu_1
jmp manu_e
manu_n: ;開始定義各個菜單項
win 0,70h,5,0,5,10
pos_curse 0,5,0
string manu_5
win 0,0fh,1,0,1,10
pos_curse 0,1,0
string manu_1
red_chr
cmp ah,48h ;向上鍵的掃描碼
je manu_e0
cmp al,0dh ;回車鍵的ASCII碼
jz new_0
cmp ah,50h
je manu_o
jmp manu_hid
manu_n0:
win 0,70h,2,0,2,10
pos_curse 0,2,0
string manu_2
jmp manu_n
new_0: jmp new_1 ;僅供中間跳轉
manu_o:
win 0,70h,1,0,1,10
pos_curse 0,1,0
string manu_1
win 0,0fh,2,0,2,10
pos_curse 0,2,0
string manu_2
red_chr
cmp ah,48h
je manu_n0
cmp al,0dh
jz open_0
cmp ah,50h
je manu_s
jmp manu_hid
new_1: jmp new_2
manu_o0:
win 0,70h,3,0,3,10
pos_curse 0,3,0
string manu_3
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -