Rev 3014 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
824 | mikedld | 1 | diff16 'tp-common.asm',0,$ |
8589 | turbocat | 2 | include '../../../debug.inc' |
258 | mikedld | 3 | ;----------------------------------------------------------------------------- |
617 | mikedld | 4 | proc clear_selection ;//////////////////////////////////////////////////////// |
258 | mikedld | 5 | ;----------------------------------------------------------------------------- |
6 | push eax ebx |
||
297 | mikedld | 7 | mov eax,[cur_editor.SelStart.Y] |
8 | mov ebx,[cur_editor.Caret.Y] |
||
258 | mikedld | 9 | cmp eax,ebx |
10 | jle @f |
||
11 | xchg eax,ebx |
||
297 | mikedld | 12 | @@: push [cur_editor.Caret.X] [cur_editor.Caret.Y] |
13 | pop [cur_editor.SelStart.Y] [cur_editor.SelStart.X] |
||
258 | mikedld | 14 | pop ebx eax |
15 | ret |
||
617 | mikedld | 16 | endp |
258 | mikedld | 17 | |
18 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 19 | proc pt_in_rect ;///////////////////////////////////////////////////////////// |
258 | mikedld | 20 | ;----------------------------------------------------------------------------- |
21 | cmp eax,[ecx+0x0] |
||
22 | jl @f |
||
23 | cmp ebx,[ecx+0x4] |
||
24 | jl @f |
||
25 | cmp eax,[ecx+0x8] |
||
26 | jg @f |
||
27 | cmp ebx,[ecx+0xC] |
||
28 | jg @f |
||
29 | stc |
||
30 | ret |
||
31 | @@: clc |
||
32 | ret |
||
617 | mikedld | 33 | endp |
258 | mikedld | 34 | |
35 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 36 | proc check_bottom_right ;///////////////////////////////////////////////////// |
258 | mikedld | 37 | ;----------------------------------------------------------------------------- |
38 | push eax |
||
297 | mikedld | 39 | mov eax,[cur_editor.TopLeft.Y] |
617 | mikedld | 40 | or eax,eax |
41 | jns @f |
||
42 | xor eax,eax |
||
43 | mov [cur_editor.TopLeft.Y],eax |
||
44 | @@: add eax,[lines.scr] |
||
297 | mikedld | 45 | cmp eax,[cur_editor.Lines.Count] |
258 | mikedld | 46 | jbe .lp1 |
297 | mikedld | 47 | mov eax,[cur_editor.Lines.Count] |
258 | mikedld | 48 | sub eax,[lines.scr] |
49 | jns @f |
||
50 | xor eax,eax |
||
297 | mikedld | 51 | @@: mov [cur_editor.TopLeft.Y],eax |
52 | .lp1: mov eax,[cur_editor.TopLeft.X] |
||
617 | mikedld | 53 | or eax,eax |
54 | jns @f |
||
55 | xor eax,eax |
||
56 | mov [cur_editor.TopLeft.X],eax |
||
57 | @@: add eax,[columns.scr] |
||
297 | mikedld | 58 | cmp eax,[cur_editor.Columns.Count] |
258 | mikedld | 59 | jbe .exit |
297 | mikedld | 60 | mov eax,[cur_editor.Columns.Count] |
258 | mikedld | 61 | sub eax,[columns.scr] |
62 | jns @f |
||
63 | xor eax,eax |
||
297 | mikedld | 64 | @@: mov [cur_editor.TopLeft.X],eax |
258 | mikedld | 65 | .exit: |
66 | pop eax |
||
67 | ret |
||
617 | mikedld | 68 | endp |
258 | mikedld | 69 | |
70 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 71 | proc get_real_length ;//////////////////////////////////////////////////////// |
258 | mikedld | 72 | ;----------------------------------------------------------------------------- |
987 | mikedld | 73 | mov eax,[esi+EDITOR_LINE_DATA.Size] |
8589 | turbocat | 74 | debug_print_dec eax |
75 | debug_print "|" |
||
987 | mikedld | 76 | @@: cmp byte[esi+eax+sizeof.EDITOR_LINE_DATA-1],' ' |
258 | mikedld | 77 | jne @f |
78 | dec eax |
||
79 | jnz @b |
||
80 | @@: ret |
||
617 | mikedld | 81 | endp |
258 | mikedld | 82 | |
83 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 84 | proc get_line_offset ;//////////////////////////////////////////////////////// |
258 | mikedld | 85 | ;----------------------------------------------------------------------------- |
86 | ; Input: |
||
87 | ; ECX = line number |
||
88 | ; Output: |
||
89 | ; ESI = line data offset |
||
90 | ;----------------------------------------------------------------------------- |
||
91 | push eax ecx |
||
297 | mikedld | 92 | mov esi,[cur_editor.Lines] |
259 | mikedld | 93 | @@: dec ecx |
94 | js .exit |
||
987 | mikedld | 95 | mov eax,[esi+EDITOR_LINE_DATA.Size] |
96 | lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA] |
||
259 | mikedld | 97 | jmp @b |
258 | mikedld | 98 | .exit: |
99 | pop ecx eax |
||
100 | ret |
||
617 | mikedld | 101 | endp |
258 | mikedld | 102 | |
103 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 104 | proc init_sel_vars ;////////////////////////////////////////////////////////// |
258 | mikedld | 105 | ;----------------------------------------------------------------------------- |
106 | pushad |
||
107 | mov [sel.selected],1 |
||
297 | mikedld | 108 | mov eax,[ebp+EDITOR.SelStart.X] |
109 | mov ebx,[ebp+EDITOR.SelStart.Y] |
||
110 | mov ecx,[ebp+EDITOR.Caret.X] |
||
111 | mov edx,[ebp+EDITOR.Caret.Y] |
||
258 | mikedld | 112 | cmp ebx,edx |
113 | jl .lp2 |
||
114 | jne @f |
||
115 | cmp eax,ecx |
||
116 | jl .lp2 |
||
117 | jne .lp1 |
||
118 | dec [sel.selected] |
||
119 | jmp .lp2 |
||
120 | @@: xchg ebx,edx |
||
121 | .lp1: xchg eax,ecx |
||
122 | .lp2: mov [sel.begin.x],eax |
||
123 | mov [sel.begin.y],ebx |
||
124 | mov [sel.end.x],ecx |
||
125 | mov [sel.end.y],edx |
||
126 | popad |
||
127 | ret |
||
617 | mikedld | 128 | endp |
258 | mikedld | 129 | |
130 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 131 | proc get_scroll_vars ;//////////////////////////////////////////////////////// |
258 | mikedld | 132 | ;----------------------------------------------------------------------------- |
133 | ; Input: |
||
134 | ; EAX = maximum data size (units) |
||
135 | ; EBX = visible data size (units) |
||
136 | ; ECX = current data position (units) |
||
137 | ; EDX = scrolling area size (pixels) |
||
138 | ; Output: |
||
139 | ; EAX = srcoller offset (pixels) |
||
140 | ; EBX = scroller size (pixels) |
||
141 | ;----------------------------------------------------------------------------- |
||
142 | push eax ebx edx |
||
143 | ; sub eax,ebx |
||
144 | mov esi,eax |
||
145 | mov eax,edx |
||
146 | imul ebx |
||
147 | idiv esi |
||
148 | cmp eax,[esp] |
||
149 | jge .null |
||
150 | cmp eax,AMINS |
||
151 | jge @f |
||
152 | neg eax |
||
153 | add eax,AMINS |
||
154 | sub [esp],eax |
||
155 | mov eax,AMINS |
||
156 | @@: mov [esp+4],eax ; scroller size |
||
157 | mov eax,[esp] |
||
158 | imul ecx |
||
159 | idiv esi |
||
160 | or eax,eax |
||
161 | jns @f |
||
162 | xor eax,eax |
||
297 | mikedld | 163 | @@: mov [esp+8],eax ; scroller offset |
258 | mikedld | 164 | add eax,[esp+4] |
165 | cmp eax,[esp] |
||
166 | jle @f |
||
167 | @@: |
||
168 | pop edx ebx eax |
||
169 | ret |
||
170 | .null: |
||
171 | mov dword[esp+4],0 |
||
172 | mov dword[esp+8],0 |
||
173 | jmp @b |
||
617 | mikedld | 174 | endp |
258 | mikedld | 175 | |
176 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 177 | proc uint2strz ;////////////////////////////////////////////////////////////// |
258 | mikedld | 178 | ;----------------------------------------------------------------------------- |
179 | dec ebx |
||
180 | jz @f |
||
181 | xor edx,edx |
||
182 | div ecx |
||
183 | push edx |
||
184 | call uint2strz |
||
185 | pop eax |
||
186 | @@: cmp al,10 |
||
187 | sbb al,$69 |
||
188 | das |
||
189 | stosb |
||
190 | ret |
||
617 | mikedld | 191 | endp |
258 | mikedld | 192 | |
193 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 194 | proc uint2str ;/////////////////////////////////////////////////////////////// |
258 | mikedld | 195 | ;----------------------------------------------------------------------------- |
196 | cmp eax,ecx |
||
197 | jb @f |
||
198 | xor edx,edx |
||
199 | div ecx |
||
200 | push edx |
||
201 | call uint2str |
||
202 | pop eax |
||
203 | @@: cmp al,10 |
||
204 | sbb al,$69 |
||
205 | das |
||
206 | stosb |
||
207 | ret |
||
617 | mikedld | 208 | endp |
258 | mikedld | 209 | |
210 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 211 | proc strlen ;///////////////////////////////////////////////////////////////// |
259 | mikedld | 212 | ;----------------------------------------------------------------------------- |
213 | push ebx |
||
214 | mov ebx,eax |
||
215 | xor eax,eax |
||
216 | @@: cmp byte[ebx+eax],0 |
||
217 | je @f |
||
218 | inc eax |
||
219 | jmp @b |
||
220 | @@: pop ebx |
||
221 | ret |
||
617 | mikedld | 222 | endp |
259 | mikedld | 223 | |
224 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 225 | proc rgb_to_gray ;//////////////////////////////////////////////////////////// |
258 | mikedld | 226 | ;----------------------------------------------------------------------------- |
227 | push 0 eax |
||
228 | and dword[esp],0x000000FF |
||
229 | fild dword[esp] |
||
230 | fmul [float_gray_b] |
||
231 | shr eax,8 |
||
232 | mov [esp],eax |
||
233 | and dword[esp],0x000000FF |
||
234 | fild dword[esp] |
||
235 | fmul [float_gray_g] |
||
236 | faddp |
||
237 | shr eax,8 |
||
238 | and eax,0x000000FF |
||
239 | mov [esp],eax |
||
240 | fild dword[esp] |
||
241 | fmul [float_gray_r] |
||
242 | faddp |
||
243 | frndint |
||
244 | fist dword[esp] |
||
245 | fist dword[esp+1] |
||
246 | fistp dword[esp+2] |
||
247 | pop eax |
||
248 | add esp,4 |
||
249 | ret |
||
617 | mikedld | 250 | endp |
258 | mikedld | 251 | |
252 | ;float_gray_r dd 0.30f |
||
253 | ;float_gray_g dd 0.59f |
||
254 | ;float_gray_b dd 0.11f |
||
255 | |||
256 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 257 | proc get_active_menu_item ;/////////////////////////////////////////////////// |
258 | mikedld | 258 | ;----------------------------------------------------------------------------- |
259 | pushad |
||
260 | mov [mi_cur],0 |
||
261 | mcall 37,1 |
||
262 | movsx ebx,ax |
||
263 | sar eax,16 |
||
264 | mov ecx,__rc |
||
265 | pushd 2 0 (main_menu.width+7) (ATOPH-2) |
||
266 | popd [__rc+0xC] [__rc+0x8] [__rc+0x4] [__rc+0x0] |
||
267 | ; add [__rc+0xC],ATOPH-2 |
||
268 | call pt_in_rect |
||
269 | jnc .outside_menu |
||
270 | m2m dword[ecx+0x8],dword[ecx+0x0] |
||
271 | mov edx,main_menu |
||
272 | @@: inc [mi_cur] |
||
273 | movzx esi,word[edx+0] |
||
274 | add [ecx+0x8],esi |
||
275 | call pt_in_rect |
||
276 | jc .exit |
||
277 | m2m dword[ecx+0x0],dword[ecx+0x8] |
||
278 | add edx,8+1 |
||
279 | movzx esi,byte[edx-1] |
||
280 | add edx,esi |
||
281 | cmp byte[edx+8],0 |
||
282 | jne @b |
||
283 | mov [mi_cur],0 |
||
284 | .exit: |
||
285 | popad |
||
286 | ret |
||
287 | .outside_menu: |
||
288 | or [mi_cur],-1 |
||
289 | @@: popad |
||
290 | ret |
||
617 | mikedld | 291 | endp |
258 | mikedld | 292 | |
293 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 294 | proc get_active_popup_item ;////////////////////////////////////////////////// |
258 | mikedld | 295 | ;----------------------------------------------------------------------------- |
296 | pushad |
||
297 | mov [pi_cur],0 |
||
298 | mcall 37,1 |
||
299 | movsx ebx,ax |
||
300 | sar eax,16 |
||
301 | mov ecx,__rc |
||
302 | mov dword[ecx+0x0],0 |
||
303 | mov dword[ecx+0x4],0 |
||
304 | movzx edx,[ebp+POPUP.width] |
||
297 | mikedld | 305 | mov dword[ecx+0x8],edx |
258 | mikedld | 306 | movzx edx,[ebp+POPUP.height] |
297 | mikedld | 307 | mov dword[ecx+0xC],edx |
258 | mikedld | 308 | call pt_in_rect |
309 | jnc .outside_window |
||
310 | inc dword[ecx+0x0] |
||
617 | mikedld | 311 | mov dword[ecx+0x4],2 |
258 | mikedld | 312 | dec dword[ecx+0x8] |
617 | mikedld | 313 | mov dword[ecx+0xC],2+POP_IHEIGHT-1 |
297 | mikedld | 314 | mov edx,[ebp+POPUP.data] |
258 | mikedld | 315 | @@: inc [pi_cur] |
316 | inc edx |
||
317 | movzx esi,byte[edx-1] |
||
318 | cmp byte[edx],'-' |
||
319 | jne .lp1 |
||
320 | pushd [ecx+0xC] |
||
617 | mikedld | 321 | sub dword[ecx+0xC],POP_IHEIGHT-POP_SHEIGHT |
258 | mikedld | 322 | call pt_in_rect |
323 | popd [ecx+0xC] |
||
324 | jc .separator |
||
617 | mikedld | 325 | add dword[ecx+0x4],POP_SHEIGHT |
326 | add dword[ecx+0xC],POP_SHEIGHT |
||
258 | mikedld | 327 | jmp .lp3 |
328 | .lp1: call pt_in_rect |
||
329 | jnc .lp2 |
||
330 | mov eax,[pi_cur] |
||
297 | mikedld | 331 | test byte[ebp+eax-1],1 |
258 | mikedld | 332 | jnz .exit |
333 | jmp .separator |
||
334 | .lp2: add dword[ecx+0x4],POP_IHEIGHT |
||
335 | add dword[ecx+0xC],POP_IHEIGHT |
||
336 | add edx,esi |
||
337 | inc edx |
||
338 | movzx esi,byte[edx-1] |
||
339 | .lp3: add edx,esi |
||
340 | cmp byte[edx],0 |
||
341 | jne @b |
||
342 | .separator: |
||
343 | mov [pi_cur],0 |
||
344 | .exit: |
||
345 | popad |
||
346 | ret |
||
347 | .outside_window: |
||
348 | or [pi_cur],-1 |
||
349 | jmp .exit |
||
617 | mikedld | 350 | endp |
258 | mikedld | 351 | |
352 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 353 | proc line_add_spaces ;//////////////////////////////////////////////////////// |
258 | mikedld | 354 | ;----------------------------------------------------------------------------- |
280 | mikedld | 355 | ; Input: |
356 | ; ESI = line offset |
||
357 | ; ECX = needed line length |
||
358 | ; Output: |
||
359 | ; EAX = delta |
||
258 | mikedld | 360 | ;----------------------------------------------------------------------------- |
280 | mikedld | 361 | xor eax,eax |
258 | mikedld | 362 | pushad |
987 | mikedld | 363 | mov edx,[esi+EDITOR_LINE_DATA.Size] |
258 | mikedld | 364 | cmp ecx,edx |
365 | jbe .exit |
||
366 | sub ecx,edx |
||
987 | mikedld | 367 | lea eax,[ecx+sizeof.EDITOR_LINE_DATA] |
280 | mikedld | 368 | call editor_realloc_lines |
369 | mov [esp+4*7],eax |
||
370 | add esi,eax |
||
258 | mikedld | 371 | push ecx |
297 | mikedld | 372 | mov edi,[cur_editor.Lines] |
987 | mikedld | 373 | add edi,[cur_editor.Lines.Size] ; !!! CHECK THIS!!! add edi,[edi-4] |
259 | mikedld | 374 | dec edi |
258 | mikedld | 375 | mov eax,esi |
376 | mov esi,edi |
||
377 | sub esi,ecx |
||
987 | mikedld | 378 | lea ecx,[eax+sizeof.EDITOR_LINE_DATA] |
297 | mikedld | 379 | add ecx,edx |
258 | mikedld | 380 | push ecx |
381 | neg ecx |
||
382 | lea ecx,[esi+ecx+1] |
||
383 | std |
||
384 | rep movsb |
||
385 | pop edi ecx |
||
987 | mikedld | 386 | add [eax+EDITOR_LINE_DATA.Size],ecx |
258 | mikedld | 387 | mov al,' ' |
388 | cld |
||
389 | rep stosb |
||
390 | .exit: |
||
391 | popad |
||
392 | ret |
||
617 | mikedld | 393 | endp |
258 | mikedld | 394 | |
395 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 396 | proc delete_selection ;/////////////////////////////////////////////////////// |
258 | mikedld | 397 | ;----------------------------------------------------------------------------- |
259 | mikedld | 398 | ; call init_sel_vars |
399 | |||
258 | mikedld | 400 | cmp [sel.selected],0 |
401 | je .exit.2 |
||
402 | |||
403 | pushad |
||
404 | mov ecx,[sel.begin.y] |
||
405 | cmp ecx,[sel.end.y] |
||
406 | je .single_line |
||
407 | call get_line_offset |
||
987 | mikedld | 408 | and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED |
409 | or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED |
||
258 | mikedld | 410 | mov ecx,[sel.begin.x] |
411 | call line_add_spaces |
||
280 | mikedld | 412 | add esi,eax |
987 | mikedld | 413 | lea edi,[esi+sizeof.EDITOR_LINE_DATA] |
258 | mikedld | 414 | mov ecx,[sel.end.y] |
415 | call get_line_offset |
||
416 | call get_real_length |
||
417 | cmp eax,[sel.end.x] |
||
418 | jbe @f |
||
419 | mov eax,[sel.end.x] |
||
987 | mikedld | 420 | @@: mov ecx,[esi+EDITOR_LINE_DATA.Size] |
258 | mikedld | 421 | sub ecx,eax |
422 | mov ebx,[sel.begin.x] |
||
423 | add ebx,ecx |
||
987 | mikedld | 424 | mov [edi-sizeof.EDITOR_LINE_DATA+EDITOR_LINE_DATA.Size],ebx |
258 | mikedld | 425 | add edi,[sel.begin.x] |
987 | mikedld | 426 | lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA] |
297 | mikedld | 427 | mov ecx,[cur_editor.Lines] |
824 | mikedld | 428 | add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4] |
258 | mikedld | 429 | sub ecx,esi |
430 | cld |
||
431 | rep movsb |
||
432 | mov eax,[sel.end.y] |
||
433 | sub eax,[sel.begin.y] |
||
297 | mikedld | 434 | sub [cur_editor.Lines.Count],eax |
258 | mikedld | 435 | jmp .exit |
436 | |||
437 | .single_line: |
||
438 | call get_line_offset |
||
987 | mikedld | 439 | and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED |
440 | or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED |
||
258 | mikedld | 441 | call get_real_length |
442 | cmp eax,[sel.begin.x] |
||
443 | jbe .exit |
||
444 | mov ecx,[sel.end.x] |
||
445 | cmp ecx,eax |
||
446 | jbe @f |
||
447 | mov ecx,eax |
||
448 | @@: sub ecx,[sel.begin.x] |
||
987 | mikedld | 449 | sub [esi+EDITOR_LINE_DATA.Size],ecx |
450 | lea edi,[esi+sizeof.EDITOR_LINE_DATA] |
||
258 | mikedld | 451 | add edi,[sel.begin.x] |
452 | lea esi,[edi+ecx] |
||
297 | mikedld | 453 | mov ecx,[cur_editor.Lines] |
824 | mikedld | 454 | add ecx,[cur_editor.Lines.Size] ;*** add ecx,[ecx-4] |
258 | mikedld | 455 | sub ecx,esi |
456 | cld |
||
457 | rep movsb |
||
458 | |||
459 | .exit: |
||
460 | mov eax,[sel.begin.x] |
||
297 | mikedld | 461 | mov [cur_editor.Caret.X],eax |
462 | mov [cur_editor.SelStart.X],eax |
||
258 | mikedld | 463 | mov eax,[sel.begin.y] |
297 | mikedld | 464 | mov [cur_editor.Caret.Y],eax |
465 | mov [cur_editor.SelStart.Y],eax |
||
280 | mikedld | 466 | |
467 | mov ecx,[cur_editor.Lines.Count] |
||
468 | call get_line_offset |
||
987 | mikedld | 469 | mov eax,[esi+EDITOR_LINE_DATA.Size] |
470 | lea esi,[esi+eax+sizeof.EDITOR_LINE_DATA] |
||
280 | mikedld | 471 | mov eax,[cur_editor.Lines] |
824 | mikedld | 472 | add eax,[cur_editor.Lines.Size] ;*** add eax,[eax-4] |
280 | mikedld | 473 | sub esi,eax |
474 | lea eax,[esi+4096] |
||
475 | call editor_realloc_lines |
||
476 | |||
258 | mikedld | 477 | popad |
297 | mikedld | 478 | mov [cur_editor.Modified],1 |
258 | mikedld | 479 | clc |
480 | ret |
||
481 | |||
482 | .exit.2: |
||
483 | stc |
||
484 | ret |
||
617 | mikedld | 485 | endp |
259 | mikedld | 486 | |
487 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 488 | proc get_selection_size ;///////////////////////////////////////////////////// |
259 | mikedld | 489 | ;----------------------------------------------------------------------------- |
490 | push ecx esi |
||
491 | mov ecx,[sel.end.y] |
||
492 | inc ecx |
||
493 | call get_line_offset |
||
494 | mov eax,esi |
||
495 | mov ecx,[sel.begin.y] |
||
496 | call get_line_offset |
||
497 | sub eax,esi |
||
498 | pop esi ecx |
||
499 | ret |
||
617 | mikedld | 500 | endp |
259 | mikedld | 501 | |
502 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 503 | proc get_lines_in_file ;////////////////////////////////////////////////////// |
259 | mikedld | 504 | ;----------------------------------------------------------------------------- |
280 | mikedld | 505 | ; Input: |
506 | ; ESI = data pointer |
||
507 | ; ECX = data length |
||
508 | ; Output: |
||
509 | ; EAX = lines number |
||
510 | ; EBX = extra length after tabs expansion |
||
259 | mikedld | 511 | ;----------------------------------------------------------------------------- |
280 | mikedld | 512 | push ecx edx esi 0 |
259 | mikedld | 513 | or ebx,-1 |
280 | mikedld | 514 | xor edx,edx |
259 | mikedld | 515 | .lp0: inc ebx |
516 | .lp1: dec ecx |
||
517 | jle .lp2 |
||
518 | lodsb |
||
280 | mikedld | 519 | cmp al,0 |
520 | je .lp2 |
||
521 | cmp al,9 |
||
522 | je .TB |
||
259 | mikedld | 523 | cmp al,10 |
524 | je .LF |
||
525 | cmp al,13 |
||
526 | je .CR |
||
280 | mikedld | 527 | inc edx |
259 | mikedld | 528 | jmp .lp1 |
280 | mikedld | 529 | .lp2: lea eax,[ebx+1] |
530 | pop ebx esi edx ecx |
||
259 | mikedld | 531 | ret |
532 | |||
533 | .CR: cmp byte[esi],10 |
||
280 | mikedld | 534 | jne .LF |
259 | mikedld | 535 | lodsb |
280 | mikedld | 536 | .LF: xor edx,edx |
537 | jmp .lp0 |
||
538 | .TB: and edx,00000111b |
||
539 | add dword[esp],ATABW |
||
540 | sub [esp],edx |
||
541 | xor edx,edx |
||
542 | jmp .lp1 |
||
617 | mikedld | 543 | endp |
259 | mikedld | 544 | |
545 | ;----------------------------------------------------------------------------- |
||
617 | mikedld | 546 | proc update_caption ;///////////////////////////////////////////////////////// |
297 | mikedld | 547 | ;----------------------------------------------------------------------------- |
548 | lea esi,[cur_editor.FilePath] |
||
549 | mov edi,s_title |
||
550 | |||
327 | mikedld | 551 | xor ecx,ecx |
297 | mikedld | 552 | @@: lodsb |
553 | cmp al,0 |
||
554 | je @f |
||
555 | stosb |
||
327 | mikedld | 556 | inc ecx |
297 | mikedld | 557 | jmp @b |
558 | @@: |
||
327 | mikedld | 559 | push ecx |
297 | mikedld | 560 | mov dword[edi],' - ' |
561 | add edi,3 |
||
327 | mikedld | 562 | mov esi,htext |
297 | mikedld | 563 | mov ecx,htext.size |
564 | cld |
||
565 | rep movsb |
||
566 | |||
567 | mov al,0 |
||
568 | stosb |
||
569 | |||
570 | mcall 71,1,s_title |
||
571 | |||
327 | mikedld | 572 | cmp [do_not_draw],0 |
573 | jne @f |
||
574 | lea esi,[cur_editor.FilePath] |
||
575 | mov edi,tb_opensave.text |
||
576 | mov ecx,[esp] |
||
577 | cld |
||
578 | rep movsb |
||
579 | pop ecx |
||
580 | mov [tb_opensave.length],cl |
||
297 | mikedld | 581 | clc |
582 | ret |
||
327 | mikedld | 583 | @@: |
584 | add esp,4 |
||
585 | clc |
||
586 | ret |
||
617 | mikedld | 587 | endp |
297 | mikedld | 588 |