📄 asmedit.inc
字号:
up_key:
test [kbstate+VK_MENU],80h
jnz scroll_up
call move_line_up
jmp moved_caret
down_key:
test [kbstate+VK_MENU],80h
jnz scroll_down
call move_line_down
jmp moved_caret
home_key:
test [kbstate+VK_CONTROL],80h
jnz screen_home
mov [caret_position],0
jmp moved_caret
end_key:
test [kbstate+VK_CONTROL],80h
jnz screen_end
call move_to_line_end
jmp moved_caret
screen_home:
mov eax,[window_line]
mov [caret_line],eax
mov eax,[window_line_number]
mov [caret_line_number],eax
jmp moved_caret
screen_end:
mov eax,[window_line_number]
add eax,[window_height]
dec eax
call find_line
mov [caret_line],esi
mov [caret_line_number],ecx
jmp moved_caret
pgup_key:
test [kbstate+VK_CONTROL],80h
jnz text_home
call move_page_up
jmp moved_caret
pgdn_key:
test [kbstate+VK_CONTROL],80h
jnz text_end
call move_page_down
jmp moved_caret
text_home:
mov eax,[first_line]
mov [caret_line],eax
mov [caret_line_number],1
jmp moved_caret
text_end:
or eax,-1
call find_line
mov [caret_line],esi
mov [caret_line_number],ecx
jmp moved_caret
word_left:
call move_to_previous_word
jmp moved_caret
word_right:
call get_caret_segment
call move_to_next_word
jmp moved_caret
scroll_left:
cmp [window_position],0
je scroll_done
dec [window_position]
jmp scroll_done
scroll_right:
inc [window_position]
jmp scroll_done
scroll_up:
mov esi,[window_line]
mov esi,[esi+4]
or esi,esi
jz scroll_done
mov [window_line],esi
dec [window_line_number]
jmp scroll_done
scroll_down:
mov esi,[window_line]
find_next_window_line:
mov esi,[esi]
btr esi,0
jc find_next_window_line
or esi,esi
jz scroll_done
mov [window_line],esi
inc [window_line_number]
scroll_done:
cmp [was_selection],0
jne moved_window
mov [selection_line],0
jmp moved_window
ins_key:
test [kbstate+VK_MENU],80h
jnz switch_blocks
test [kbstate+VK_CONTROL],80h
jnz wm_copy
test [kbstate+VK_SHIFT],80h
jnz wm_paste
xor [editor_mode],AEMODE_OVERWRITE
mov [notification],AEN_MODECHANGE
call create_caret
cmp [was_selection],1
je done
mov [selection_line],0
jmp done
del_key:
test [kbstate+VK_CONTROL],80h
jnz wm_clear
test [kbstate+VK_SHIFT],80h
jnz wm_cut
cmp [was_selection],0
je no_selection_on_del
test [editor_style],AES_SECURESEL
jz wm_clear
no_selection_on_del:
mov esi,[caret_line]
test [editor_mode],AEMODE_OVERWRITE
jnz delete_char
call check_line_length
cmp ecx,[caret_position]
ja delete_char
cmp dword [esi],0
je ignore
call store_status_for_undo
call cut_line_break
mov esi,[caret_line]
call check_line_length
jmp text_altered
delete_char:
mov [current_operation],VK_DELETE
cmp [last_operation],VK_DELETE
je undo_delete_ok
call store_status_for_undo
undo_delete_ok:
call delete_character
mov esi,[caret_line]
call check_line_length
jmp text_altered
backspace_key:
test [kbstate+VK_MENU],80h
jnz wm_undo
cmp [was_selection],0
je no_selection_to_clear
test [editor_style],AES_SECURESEL
jz wm_clear
no_selection_to_clear:
cmp [caret_position],0
je line_back
test [kbstate+VK_CONTROL],80h
jnz word_back
mov [current_operation],VK_BACK
cmp [last_operation],VK_BACK
je undo_back_ok
call store_status_for_undo
undo_back_ok:
dec [caret_position]
call delete_character
mov esi,[caret_line]
call check_line_length
jmp text_altered
line_back:
test [editor_mode],AEMODE_OVERWRITE
jnz ignore
mov esi,[caret_line]
mov esi,[esi+4]
or esi,esi
jz ignore
call store_status_for_undo
mov [caret_line],esi
dec [caret_line_number]
call check_line_length
mov [caret_position],ecx
call cut_line_break
mov esi,[caret_line]
call check_line_length
jmp text_altered
word_back:
call store_status_for_undo
push [caret_position]
mov esi,[caret_line]
xor eax,eax
xchg eax,[esi+4]
push eax
call move_to_previous_word
pop eax
mov esi,[caret_line]
mov [esi+4],eax
pop ecx
sub ecx,[caret_position]
call delete_from_line
mov esi,[caret_line]
call check_line_length
jmp text_altered
character:
cmp al,0Dh
je enter_key
cmp al,9
je tab_key
cmp [was_selection],0
je no_selection_to_replace
call store_status_for_undo
test [editor_style],AES_SECURESEL
jnz character_undo_ok
push eax
call delete_block
pop eax
call put_character
mov esi,[caret_line]
call check_line_length
jmp text_altered
no_selection_to_replace:
mov [current_operation],VK_SPACE
cmp [last_operation],VK_SPACE
je character_undo_ok
call store_status_for_undo
character_undo_ok:
call put_character
mov esi,[caret_line]
call check_line_length
jmp text_altered
tab_key:
call store_status_for_undo
cmp [was_selection],0
je tab_securesel
test [editor_style],AES_SECURESEL
jnz tab_securesel
call delete_block
tab_securesel:
call tabulate
mov esi,[caret_line]
call check_line_length
jmp text_altered
enter_key:
call store_status_for_undo
cmp [was_selection],0
je enter_secureselection_ok
test [editor_style],AES_SECURESEL
jnz enter_secureselection_ok
call delete_block
enter_secureselection_ok:
call carriage_return
test [editor_mode],AEMODE_OVERWRITE
jnz text_altered
mov esi,[caret_line]
call check_line_length
jmp text_altered
ctrl_y_key:
call remove_line
jmp text_altered
f6_key:
call duplicate_line
jmp text_altered
menu_key:
cmp [menu_handle],0
je ignore
lea ebx,[point]
mov eax,[caret_x]
mov [ebx+POINT.x],eax
mov eax,[caret_y]
add eax,[font_height]
mov [ebx+POINT.y],eax
invoke ClientToScreen,[hwnd],ebx
invoke TrackPopupMenu,[menu_handle],TPM_RIGHTBUTTON,[ebx+POINT.x],[ebx+POINT.y],0,[menu_window],0
jmp ignore
wm_syskeydown:
mov eax,[wparam]
cmp eax,VK_INSERT
je switch_blocks
cmp eax,VK_BACK
je wm_undo
cmp eax,VK_LEFT
je scroll_left
cmp eax,VK_RIGHT
je scroll_right
cmp eax,VK_UP
je scroll_up
cmp eax,VK_DOWN
je scroll_down
mov al,[last_operation]
mov [current_operation],al
invoke ShowCaret,[hwnd]
jmp defwndproc
switch_blocks:
xor [editor_mode],AEMODE_VERTICALSEL
mov [notification],AEN_MODECHANGE
cmp [was_selection],0
je ignore
jmp moved_window
wm_char:
test [lparam],1 shl 31
jz ignore
mov eax,[wparam]
jmp character
wm_lbuttondown:
cmp [focus],0
jne focus_ok
invoke SetFocus,[hwnd]
mov esi,[editor_memory]
add esi,16
lea edi,[editor_data]
mov ecx,editor_data_size
rep movsb
focus_ok:
lea ebx,[kbstate]
invoke GetKeyboardState,ebx
cmp [was_selection],0
jne selection_ok
mov eax,[caret_line]
mov [selection_line],eax
mov eax,[caret_position]
mov [selection_position],eax
mov eax,[caret_line_number]
mov [selection_line_number],eax
selection_ok:
call get_mouse_position
invoke SetCapture,[hwnd]
or [mouse_select],-1
jmp moved_caret
get_mouse_position:
mov ax,word [lparam]
cwde
cdq
test [editor_style],AES_CONSOLECARET
jnz get_mouse_column
test [editor_mode],AEMODE_OVERWRITE
jnz get_mouse_column
mov ebx,[font_width]
shr ebx,1
adc eax,ebx
get_mouse_column:
idiv [font_width]
add eax,[window_position]
cmp eax,[maximum_position]
jg mouse_out_of_line
cmp eax,0
jge click_position_ok
xor eax,eax
jmp click_position_ok
mouse_out_of_line:
mov eax,[maximum_position]
click_position_ok:
mov [caret_position],eax
mov ax,word [lparam+2]
cwde
cdq
idiv [font_height]
add eax,[window_line_number]
cmp eax,0
jg click_line_ok
mov eax,1
click_line_ok:
call find_line
mov [caret_line],esi
mov [caret_line_number],ecx
retn
wm_lbuttonup:
invoke ReleaseCapture
mov [mouse_select],0
jmp done
wm_mousemove:
cmp [mouse_select],0
je ignore
cmp [was_selection],0
jne select
mov eax,[caret_line]
mov ebx,[caret_line_number]
mov [selection_line],eax
mov [selection_line_number],ebx
mov eax,[caret_position]
mov [selection_position],eax
select:
call get_mouse_position
jmp moved_selection
wm_lbuttondblclk:
mov [mouse_select],0
call get_mouse_position
call get_word_at_caret
mov [selection_position],edx
add edx,ecx
mov [caret_position],edx
mov eax,[caret_line]
mov [selection_line],eax
mov eax,[caret_line_number]
mov [selection_line_number],eax
jmp moved_selection
wm_rbuttondown:
cmp [menu_handle],0
je ignore
lea eax,[point]
invoke GetCursorPos,eax
invoke TrackPopupMenu,[menu_handle],TPM_RIGHTBUTTON,[point.x],[point.y],0,[menu_window],0
jmp ignore
wm_copy:
cmp [was_selection],0
je ignore
call copy_to_clipboard
jmp ignore
copy_to_clipboard:
call get_block_length
inc ecx
invoke GlobalAlloc,GMEM_MOVEABLE+GMEM_DDESHARE,ecx
mov ebx,eax
invoke GlobalLock,ebx
mov edi,eax
push ebx
call copy_block
pop ebx
invoke GlobalUnlock,ebx
invoke OpenClipboard,[hwnd]
invoke EmptyClipboard
invoke SetClipboardData,CF_TEXT,ebx
or eax,eax
jz copy_failed
invoke CloseClipboard
retn
copy_failed:
invoke GlobalFree,ebx
retn
wm_cut:
cmp [was_selection],0
je ignore
call copy_to_clipboard
wm_clear:
cmp [was_selection],0
je ignore
call store_status_for_undo
call delete_block
mov [selection_line],0
jmp text_changed
wm_paste:
call store_status_for_undo
cmp [was_selection],0
je paste_secureselection_ok
test [editor_style],AES_SECURESEL
jnz paste_secureselection_ok
call delete_block
paste_secureselection_ok:
invoke OpenClipboard,NULL
invoke GetClipboardData,CF_TEXT
or eax,eax
jnz do_paste
invoke CloseClipboard
jmp ignore
do_paste:
or [clipboard_opened],-1
push eax
invoke GlobalLock,[esp]
mov esi,eax
call insert_block
jc paste_failed
pop ebx
invoke GlobalUnlock,ebx
invoke CloseClipboard
mov [clipboard_opened],0
test [editor_style],AES_SECURESEL
jz no_selection_after_paste
mov eax,[caret_line]
mov ecx,[caret_line_number]
mov edx,[caret_position]
xchg eax,[selection_line]
xchg ecx,[selection_line_number]
xchg edx,[selection_position]
mov [caret_line],eax
mov [caret_line_number],ecx
mov [caret_position],edx
jmp text_changed
no_selection_after_paste:
mov [selection_line],0
jmp text_changed
paste_failed:
call undo_changes
pop ebx
invoke GlobalUnlock,ebx
invoke CloseClipboard
mov [clipboard_opened],0
jmp text_changed
wm_settext:
mov esi,[lparam]
call set_text
mov [return_value],TRUE
jmp text_changed
wm_gettextlength:
mov esi,[first_line]
count_text_length:
mov eax,[esi+8]
add [return_value],eax
skip_counted_line_segments:
mov esi,[esi]
or esi,esi
jz ignore
btr esi,0
jc skip_counted_line_segments
add [return_value],2
jmp count_text_length
wm_gettext:
mov esi,[first_line]
mov edi,[lparam]
sub [wparam],1
jc ignore
copy_text:
mov ecx,[esi+8]
test [editor_style],AES_OPTIMALFILL
jz direct_copy
cmp ecx,8
jb direct_copy
push edi ecx
mov edi,[line_buffer]
xor edx,edx
call copy_from_line
push esi
mov esi,[line_buffer]
mov edi,[line_buffer]
add edi,[peak_line_length]
mov ebx,edi
mov ecx,[esp+4]
xor al,al
rep stosb
mov ecx,[esp+4]
invoke syntax_proc,esi,ecx,ebx
pop esi ecx edi
mov eax,[return_value]
add eax,ecx
cmp eax,[wparam]
jbe optimal_fill_size_ok
mov ecx,[wparam]
sub eax,[return_value]
optimal_fill_size_ok:
push esi edi
mov esi,[line_buffer]
mov ebx,[peak_line_length]
jecxz optimal_fill_done
xor edx,edx
optimal_fill:
lodsb
cmp al,20h
jne store_character
cmp byte [esi-1+ebx],0
jne store_character
mov eax,esi
sub eax,[line_buffer]
test eax,111b
jz store_tab
inc edx
mov al,20h
stosb
loop optimal_fill
jmp optimal_fill_done
store_tab:
mov al,20h
or edx,edx
jz store_character
sub edi,edx
mov al,9
store_character:
stosb
xor edx,edx
loop optimal_fill
optimal_fill_done:
pop eax
neg eax
add eax,edi
add [return_value],eax
pop esi
jmp line_copied
direct_copy:
mov eax,[return_value]
add eax,ecx
cmp eax,[wparam]
jbe direct_copy_size_ok
mov ecx,[wparam]
sub eax,[return_value]
direct_copy_size_ok:
add [return_value],ecx
xor edx,edx
call copy_from_line
line_copied:
or esi,esi
jz text_copied
mov ecx,[return_value]
add ecx,2
cmp ecx,[wparam]
ja text_copied
mov ax,0A0Dh
stosw
mov [return_value],ecx
cmp ecx,[wparam]
jne copy_text
text_copied:
xor al,al
stosb
jmp ignore
aem_getlinelength:
mov esi,[caret_line]
mov eax,[wparam]
or eax,eax
jz return_length
call find_line
cmp ecx,[wparam]
je return_length
or [return_value],-1
jmp ignore
return_length:
mov ecx,[esi+8]
mov [return_value],ecx
jmp ignore
aem_getline:
mov esi,[caret_line]
mov eax,[wparam]
or eax,eax
jz get_line
call find_line
cmp ecx,[wparam]
jne ignore
get_line:
mov ecx,[esi+8]
mov [return_value],ecx
mov edi,[lparam]
xor edx,edx
call copy_from_line
xor al,al
stosb
jmp ignore
wm_setfont:
mov esi,[wparam]
or esi,esi
jnz get_metrics
mov esi,[asmedit_font]
get_metrics:
invoke GetDC,[hwnd]
mov ebx,eax
invoke SelectObject,ebx,esi
lea edi,[char]
mov byte [edi],20h
lea eax,[size]
invoke GetTextExtentPoint32,ebx,edi,1,eax
lea eax,[tm]
invoke GetTextMetrics,ebx,eax
invoke ReleaseDC,[hwnd],ebx
test [tm.tmPitchAndFamily],TMPF_FIXED_PITCH
jnz ignore
mov [return_value],esi
mov [editor_font],esi
mov eax,[size.cy]
mov [font_height],eax
mov eax,[size.cx]
mov [font_width],eax
call create_caret
mov eax,[lparam]
mov [redraw_now],al
jmp wm_size
wm_getfont:
mov eax,[editor_font]
cmp eax,[asmedit_font]
je ignore
mov [return_value],eax
jmp ignore
wm_undo:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -