Tinypad 4.0.4 (final release)

git-svn-id: svn://kolibrios.org@297 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Mihail Semenyako (mike.dld)
2007-01-27 23:36:07 +00:00
parent c3a36dffbc
commit b542bfb588
17 changed files with 1639 additions and 2023 deletions

View File

@@ -17,11 +17,11 @@ func draw_editor ;///// DRAW EDITOR //////////////////////////////////////////
mov [cur_editor.Gutter.Visible],0
test [options],OPTS_LINENUMS
jnz @f
xor eax,eax ;! mov eax,2+LCHGW
xor eax,eax
jmp .lp1
@@: inc [cur_editor.Gutter.Visible]
mov edi,p_info+100
mov eax,[cur_editor.Lines.Count] ;! eax,[lines]
mov eax,[cur_editor.Lines.Count]
mov ecx,10
call uint2str
lea eax,[edi-p_info-100]
@@ -30,7 +30,7 @@ func draw_editor ;///// DRAW EDITOR //////////////////////////////////////////
mov eax,3
@@: imul eax,6
add eax,8
.lp1: mov [cur_editor.Gutter.Width],eax ;! [left_ofs],eax
.lp1: mov [cur_editor.Gutter.Width],eax
mov [left_ofs],eax
mov eax,[cur_editor.Bounds.Right]
@@ -131,8 +131,10 @@ func draw_editor_vscroll ;///// DRAW EDITOR VERTICAL SCROLL BAR //////////////
add ebx,(-SCRLW)*65536+SCRLW
mov ecx,[cur_editor.Bounds.Top-2]
mov cx,SCRLW
cmp [bot_mode],0
jne @f
mcall 8,,,'VSL' or 0x40000000
pushad
@@: pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
@@ -152,8 +154,10 @@ func draw_editor_vscroll ;///// DRAW EDITOR VERTICAL SCROLL BAR //////////////
mov ecx,[cur_editor.Bounds.Bottom]
shl ecx,16
add ecx,(-SCRLW*2)*65536+SCRLW
cmp [bot_mode],0
jne @f
mcall ,,,'VSG' or 0x40000000
pushad
@@: pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
@@ -236,8 +240,10 @@ func draw_editor_hscroll ;///// DRAW EDITOR HORIZONTAL SCROLL BAR ////////////
mov ecx,[cur_editor.Bounds.Bottom]
shl ecx,16
add ecx,(-SCRLW)*65536+SCRLW
cmp [bot_mode],0
jne @f
mcall 8,,,'HSL' or 0x40000000
pushad
@@: pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
@@ -256,8 +262,10 @@ func draw_editor_hscroll ;///// DRAW EDITOR HORIZONTAL SCROLL BAR ////////////
mov ebx,[cur_editor.Bounds.Right]
shl ebx,16
add ebx,(-SCRLW*2)*65536+SCRLW
cmp [bot_mode],0
jne @f
mcall 8,,,'HSG' or 0x40000000
pushad
@@: pushad
sar ebx,16
sar ecx,16
push ebx ecx SCRLW SCRLW
@@ -332,6 +340,82 @@ func draw_editor_hscroll ;///// DRAW EDITOR HORIZONTAL SCROLL BAR ////////////
ret
endf
;-----------------------------------------------------------------------------
func draw_editor_text.part ;///// DRAW EDITOR TEXT (PARTLY) //////////////////
;-----------------------------------------------------------------------------
; EAX = start line
; EBX = end line
;-----------------------------------------------------------------------------
cmp [cur_editor.Lines],0
jne @f
ret
@@: push eax
mov eax,[cur_editor.Bounds.Bottom]
sub eax,[cur_editor.Bounds.Top]
cmp eax,LINEH
pop eax
jge @f
ret
@@:
mov ebp,cur_editor
call init_sel_vars
call check_bottom_right
pushad
push eax
mov eax,[cur_editor.Bounds.Left]
add eax,[cur_editor.Gutter.Width]
add eax,LCHGW+3
mov [left_ofs],eax
mov eax,[cur_editor.Bounds.Top]
add eax,3
mov [top_ofs],eax
pop eax
cmp [lines.scr],0
jle .exit
cmp eax,ebx
jle @f
xchg eax,ebx
@@: cmp eax,[cur_editor.TopLeft.Y]
jge @f
mov eax,[cur_editor.TopLeft.Y]
@@: mov ecx,[cur_editor.TopLeft.Y]
add ecx,[lines.scr]
cmp ebx,ecx
jl @f
dec ecx
mov ebx,ecx
@@: cmp eax,ebx
jg .exit
mov ecx,eax
push eax
call get_line_offset
.start:
mov ecx,ebx
sub ecx,eax
inc ecx
mov ebx,[top_ofs]
add ebx,[left_ofs-2]
sub eax,[cur_editor.TopLeft.Y]
imul eax,LINEH
add ebx,eax
imul ebp,[cur_editor.TopLeft.X],6*65536
mov [draw_blines],0
jmp draw_editor_text.next_line
.exit:
popad
ret
endf
;-----------------------------------------------------------------------------
func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
;-----------------------------------------------------------------------------
@@ -344,6 +428,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
jge @f
ret
@@:
mov ebp,cur_editor
call init_sel_vars
call check_bottom_right
@@ -360,7 +445,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
mov ebx,[top_ofs]
add ebx,[left_ofs-2]
mov ecx,[cur_editor.TopLeft.Y] ;! ecx,[top_line]
mov ecx,[cur_editor.TopLeft.Y]
push ecx
call get_line_offset
@@ -371,7 +456,8 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
jle .exit
add esp,-4
imul ebp,[cur_editor.TopLeft.X],6*65536 ;! ebp,[left_col],6*65536
imul ebp,[cur_editor.TopLeft.X],6*65536
mov [draw_blines],1
.next_line:
@@ -381,7 +467,6 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
shl ecx,16
mov cl,LINEH
mov ebx,[cur_editor.Bounds.Right]
;sub ebx,[cur_editor.Bounds.Left]
add ebx,-SCRLW
add ebx,[left_ofs-2]
sub ebx,[left_ofs]
@@ -389,7 +474,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
; selection (text background)
mov [in_sel],0
mov edx,[color_tbl+4*5]
mov edx,[color_tbl.back]
mov eax,[esp+4*2]
cmp eax,[sel.begin.y]
jl .lp6
@@ -402,7 +487,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
cmp eax,[sel.end.y]
je .lp5
.lp2: mov eax,[sel.begin.x]
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
jle .lp6.2
cmp eax,[columns.scr]
jge .lp6
@@ -414,7 +499,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add ebx,[left_ofs]
add ebx,-2
rol ebx,16
mov edx,[color_tbl+4*7]
mov edx,[color_tbl.back.sel]
mcall 13
popad
mov bx,ax
@@ -424,7 +509,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
cmp eax,[sel.end.y]
je .lp5
.lp4: mov eax,[sel.end.x]
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
jle .lp6
cmp eax,[columns.scr]
jg .lp6.2
@@ -432,18 +517,18 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
pushad
sub bx,ax
rol ebx,16
add eax,[left_ofs];OLEFT-1
add eax,[left_ofs]
add eax,-2
mov bx,ax
rol ebx,16
mcall 13
popad
inc eax
mov edx,[color_tbl+4*7]
mov edx,[color_tbl.back.sel]
mov bx,ax
mov [in_sel],3
jmp .lp6
.lp5: mov eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
.lp5: mov eax,[cur_editor.TopLeft.X]
cmp eax,[sel.begin.x]
jge .lp4
add eax,[columns.scr]
@@ -452,7 +537,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
mov eax,[sel.begin.x]
cmp eax,[sel.end.x]
je .lp6
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
imul eax,6
pushad
mov ebx,[sel.end.x]
@@ -463,7 +548,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add eax,[left_ofs]
mov bx,ax
rol ebx,16
mov edx,[color_tbl+4*7]
mov edx,[color_tbl.back.sel]
mcall 13
movzx eax,bx
sar ebx,16
@@ -475,7 +560,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add ax,word[left_ofs]
add ax,-2
mov bx,ax
mov edx,[color_tbl+4*5]
mov edx,[color_tbl.back]
mcall 13
popad
mov bx,ax
@@ -483,7 +568,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
jmp .lp6
.lp6.2:
mov edx,[color_tbl+4*7]
mov edx,[color_tbl.back.sel]
inc [in_sel]
.lp6:
mcall 13
@@ -491,13 +576,13 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
lodsd
pushad
mov edx,[color_tbl+4*5]
mov edx,[color_tbl.back]
test eax,0x00010000
jz @f
mov edx,[color_tbl+4*8]
mov edx,[color_tbl.line.moded]
test eax,0x00020000
jz @f
mov edx,[color_tbl+4*9]
mov edx,[color_tbl.line.saved]
@@: mov ebx,[left_ofs]
add ebx,-LCHGW-2;-4
@@ -513,12 +598,12 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
or eax,eax
ja .next_block
add esp,4*2
jmp .exit ; .draw_cursor
jmp .exit
.next_block:
push esi ecx
call get_next_part
call .get_next_part
pop ebx
push ecx
@@ -526,30 +611,28 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
push esi ebx
mov eax,ebx
sub ebx,[cur_editor.TopLeft.X] ;! ebx,[left_col]
sub ebx,[cur_editor.TopLeft.X]
cmp ebx,[columns.scr]
jge .skip_t
add ebx,esi
jle .skip_t
mov ebx,[esp+8+4*2] ;// 4*2=esi+ebx
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
jge .qqq
sub edx,eax
add esi,eax
; mov eax,OLEFT*65536
xor eax,eax
jmp .qqq2
.qqq:
; inc eax
imul eax,6*65536
.qqq2:
and ebx,0x0000FFFF
add eax,[left_ofs-2];OLEFT*65536
add eax,[left_ofs-2]
add ebx,eax
mov eax,[esp] ; ebx
add eax,[esp+4] ; esi
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
sub eax,[columns.scr]
jle .qweqwe
sub esi,eax
@@ -573,7 +656,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
mov esi,[sel.begin.x]
sub esi,[esp]
pushad
mov ecx,[cur_editor.TopLeft.X] ;! ecx,[left_col]
mov ecx,[cur_editor.TopLeft.X]
sub ecx,[esp+4*8]
jle @f
sub esi,ecx
@@ -585,7 +668,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add bx,si
rol ebx,16
mov esi,eax
mov ecx,[color_tbl+4*6]
mov ecx,[color_tbl.text.sel]
mcall 4
popad
jmp .draw_t
@@ -603,14 +686,14 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
sub eax,[esp]
push ebx
mov ebx,[esp+4]
sub ebx,[cur_editor.TopLeft.X] ;! ebx,[left_col]
sub ebx,[cur_editor.TopLeft.X]
jge .ya2.1
add eax,ebx
.ya2.1:
pop ebx
pushad
mov esi,eax
mov ecx,[color_tbl+4*6]
mov ecx,[color_tbl.text.sel]
mcall 4
popad
sub esi,eax
@@ -635,7 +718,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
sub esi,[esp]
push eax
mov eax,[esp+4]
sub eax,[cur_editor.TopLeft.X] ;! eax,[left_col]
sub eax,[cur_editor.TopLeft.X]
jge .nt3.1
add esi,eax
.nt3.1:
@@ -647,7 +730,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add ebx,esi
mov esi,[sel.end.x]
sub esi,[sel.begin.x]
mov ecx,[color_tbl+4*6]
mov ecx,[color_tbl.text.sel]
sub eax,esi
push eax
mcall 4
@@ -665,30 +748,32 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
cmp eax,[sel.end.x]
jge .ya2
;---[ block inside selection ]-----------------(-
.ya4: mov ecx,[color_tbl+4*6]
.ya4: mov ecx,[color_tbl.text.sel]
;----------------------------------------------)-
.draw_t:
mcall 4;[esp+8]
mcall 4
.skip_t:
pop eax eax ; ebx esi
imul eax,6
add [esp+4*2+2],ax
pop ecx esi
cmp ecx,[cur_line_len];LINE_WIDTH
cmp ecx,[cur_line_len]
jl .next_block
pop ebx ecx
and ebx,0x0000FFFF
add ebx,[left_ofs-2]
add ebx,LINEH
add esi,[cur_line_len];LINE_WIDTH
add esi,[cur_line_len]
inc dword[esp]
dec ecx
jg .next_line
.exit:
cmp [draw_blines],0
je .exit.2
mov eax,[cur_editor.Bounds.Left]
add eax,[cur_editor.Gutter.Width]
inc eax
@@ -697,7 +782,7 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
mov bx,word[cur_editor.Bounds.Right]
sub bx,ax
add ebx,-SCRLW
mov edx,[color_tbl+4*5]
mov edx,[color_tbl.back]
mov eax,13
mov ecx,[esp-8]
add ecx,LINEH
@@ -719,11 +804,130 @@ func draw_editor_text ;///// DRAW EDITOR TEXT ////////////////////////////////
add ecx,-(SCRLW-1)*65536+SCRLW-1
mcall
.exit.2:
popad
add esp,4
ret
endf
;-----------------------------------------------------------------------------
func draw_editor_text.get_next_part ;/////////////////////////////////////////
;-----------------------------------------------------------------------------
; Input:
; ECX = current letter
; ESI = string
; Output:
; ECX = color
; EDX = string
; ESI = length
;-----------------------------------------------------------------------------
cmp [cur_editor.AsmMode],0
je .plain.text
xor ebx,ebx
mov edx,ecx
add esi,ecx
mov edi,symbols
mov al,[esi]
cmp al,';'
je .comment
mov ecx,symbols.size
repne scasb
je .symbol
cmp al,'$'
jne @f
mov edi,symbols
mov al,[esi+1]
mov ecx,symbols.size
repne scasb
je .not_symbol
jmp .number
@@: cmp al,'0'
jb @f
cmp al,'9'
jbe .number
@@: cmp al,"'"
je .string
cmp al,'"'
je .string
.not_symbol:
inc ebx
inc edx
cmp edx,[cur_line_len]
jge @f
mov edi,symbols
mov al,[esi+ebx]
cmp al,';'
je @f
mov ecx,symbols.size
repne scasb
jne .not_symbol
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl.text]
ret
.symbol:
inc ebx
inc edx
cmp edx,[cur_line_len]
jge @f
mov edi,symbols
mov al,[esi+ebx]
mov ecx,symbols.size
repne scasb
je .symbol
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl.symbol]
ret
.comment:
neg edx
add edx,[cur_line_len]
xchg edx,esi
mov ecx,[cur_line_len]
mov eax,[color_tbl.comment]
ret
.number:
inc ebx
inc edx
cmp edx,[cur_line_len]
jge @f
mov edi,symbols
mov al,[esi+ebx]
cmp al,';'
je @f
mov ecx,symbols.size
repne scasb
jne .number
@@: mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl.number]
ret
.string:
inc ebx
inc edx
cmp edx,[cur_line_len]
jge @f
cmp [esi+ebx],al
jne .string
inc ebx
inc edx
@@:
mov ecx,edx
mov edx,esi
mov esi,ebx
mov eax,[color_tbl.string]
ret
.plain.text:
mov edx,[cur_line_len]
xchg edx,esi
mov ecx,[cur_line_len]
mov eax,[color_tbl.text]
ret
endf
;-----------------------------------------------------------------------------
func draw_editor_caret ;///// DRAW EDITOR TEXT CARET /////////////////////////
;-----------------------------------------------------------------------------
@@ -781,3 +985,188 @@ func editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
pop ecx ebx
ret
endf
REDRAW_TEXT = 00000001b
REDRAW_HSCROLL = 00000010b
REDRAW_VSCROLL = 00000100b
REDRAW_ONELINE = 00001000b
REDRAW_TWOLINES = 00010000b
;-----------------------------------------------------------------------------
func editor_check_for_changes ;///// EDITOR CHANGES CHECKER //////////////////
;-----------------------------------------------------------------------------
call .check_cursor_visibility
xor edx,edx
mov eax,[cur_editor.TopLeft.Y]
cmp eax,[checker_ed.TopLeft.Y]
je @f
or dl,REDRAW_TEXT+REDRAW_VSCROLL
@@: mov eax,[cur_editor.TopLeft.X]
cmp eax,[checker_ed.TopLeft.X]
je @f
or dl,REDRAW_TEXT+REDRAW_HSCROLL
@@: or dl,dl
jnz .redraw
mov eax,[cur_editor.Caret.Y]
cmp eax,[checker_ed.Caret.Y]
je @f
or dl,REDRAW_TWOLINES
@@: mov eax,[cur_editor.Caret.X]
cmp eax,[checker_ed.Caret.X]
je @f
or dl,REDRAW_ONELINE
@@: mov ebp,cur_editor
call init_sel_vars
mov al,[sel.selected]
mov ebp,checker_ed
call init_sel_vars
cmp al,[sel.selected]
je @f
cmp al,0
je .clear_sel
jmp .draw_sel
@@: cmp al,0
jne .redraw_sel
or dl,dl
jz .exit
test dl,REDRAW_TWOLINES
jz .one_line
push edx
mov eax,[checker_ed.Caret.Y]
mov ebx,eax
call draw_editor_text.part
pop edx
.one_line:
mov eax,[cur_editor.Caret.Y]
mov ebx,eax
call draw_editor_text.part
call draw_editor_caret
jmp .exit
.clear_sel:
;// use checker_ed
mov eax,[sel.begin.y]
mov ebx,[sel.end.y]
push eax ebx
call draw_editor_text.part
pop edx ecx
mov eax,[cur_editor.Caret.Y]
cmp eax,ecx
jb @f
cmp eax,edx
jbe .lp1
@@: mov ebx,eax
call draw_editor_text.part
.lp1: call draw_editor_caret
jmp .exit
.draw_sel:
;// use cur_editor
mov ebp,cur_editor
call init_sel_vars
mov eax,[sel.begin.y]
mov ebx,[sel.end.y]
push eax ebx
call draw_editor_text.part
pop edx ecx
mov eax,[checker_ed.Caret.Y]
cmp eax,ecx
jb @f
cmp eax,edx
jbe .lp2
@@: mov ebx,eax
call draw_editor_text.part
.lp2: call draw_editor_caret
jmp .exit
.redraw_sel:
;// use checker_ed and cur_editor
mov eax,[checker_ed.Caret.Y]
mov ebx,[cur_editor.Caret.Y]
cmp eax,ebx
jb @f
xchg eax,ebx
@@: call draw_editor_text.part
call draw_editor_caret
jmp .exit
.redraw:
push edx
call draw_editor_gutter
call draw_editor_text
call draw_editor_caret
test byte[esp],REDRAW_VSCROLL
jz @f
call draw_editor_vscroll
@@: pop edx
test dl,REDRAW_HSCROLL
jz @f
call draw_editor_hscroll
@@: jmp .exit
.exit:
mov esi,cur_editor
mov edi,checker_ed
mov ecx,sizeof.EDITOR/4
cld
rep movsd
ret
.check_cursor_visibility:
push eax ebx
.chk_y:
mov eax,[cur_editor.Caret.Y]
or eax,eax
jge @f
mov [cur_editor.Caret.Y],0
jmp .chk_dy
@@: cmp eax,[cur_editor.Lines.Count]
jl .chk_dy
mov eax,[cur_editor.Lines.Count]
dec eax
mov [cur_editor.Caret.Y],eax
.chk_dy:
mov eax,[cur_editor.TopLeft.Y]
cmp eax,[cur_editor.Caret.Y]
jle @f
m2m [cur_editor.TopLeft.Y],[cur_editor.Caret.Y]
@@: add eax,[lines.scr]
cmp eax,[cur_editor.Caret.Y]
jg .chk_x
mov eax,[cur_editor.Caret.Y]
sub eax,[lines.scr]
inc eax
mov [cur_editor.TopLeft.Y],eax
.chk_x:
mov eax,[cur_editor.Caret.X]
or eax,eax
jge @f
mov [cur_editor.Caret.X],0
jmp .chk_dx
@@: cmp eax,[cur_editor.Columns.Count]
jl .chk_dx
mov eax,[cur_editor.Columns.Count]
mov [cur_editor.Caret.X],eax
.chk_dx:
mov eax,[cur_editor.TopLeft.X]
cmp eax,[cur_editor.Caret.X]
jle @f
m2m [cur_editor.TopLeft.X],[cur_editor.Caret.X]
@@: add eax,[columns.scr]
cmp eax,[cur_editor.Caret.X]
jg @f
mov eax,[cur_editor.Caret.X]
sub eax,[columns.scr]
inc eax
mov [cur_editor.TopLeft.X],eax
@@: cmp [mev],MEV_LDOWN
jne @f
push [cur_editor.Caret.X] [cur_editor.Caret.Y]
pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X]
@@: pop ebx eax
ret
endf