Rev 997 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
814 | diamond | 1 | virtual at 0 |
2 | editor_data: |
||
3 | .hPlugin dd ? |
||
4 | .hFile dd ? |
||
5 | if (.hPlugin <> viewer_data.hPlugin) | (.hFile <> viewer_data.hFile) |
||
6 | error in viewer_IsHandleUsed/editor_IsHandleUsed |
||
7 | end if |
||
8 | .memsize dd ? |
||
9 | .encoding db ? |
||
10 | .flags db ? ; & 0x80: modified |
||
11 | ; & 0x40: file is locked |
||
12 | ; & 0x20: next key as a symbol |
||
13 | ; & 0x10: replace mode (vs insert) |
||
14 | .eol db ? |
||
15 | rb 1 |
||
16 | .first_block dd ? |
||
17 | .last_block dd ? |
||
18 | .numfree dd ? |
||
19 | .freeblocks dd ? |
||
20 | .numlines dd ? |
||
21 | .curline dd ? |
||
22 | .curcol dd ? |
||
23 | ;.curpos_block dd ? |
||
24 | ;.curpos_offs dd ? |
||
25 | .cur_block dd ? |
||
26 | .cur_offs dd ? |
||
27 | .cur_delta dd ? |
||
28 | .cursor_x dd ? |
||
29 | .cursor_y dd ? |
||
30 | align 200h |
||
31 | .filename rb 1024 |
||
32 | .hostname rb 1024 |
||
33 | if (.filename <> viewer_data.filename) | (.hostname <> viewer_data.hostname) |
||
34 | error in viewer_getname/editor_getname |
||
35 | end if |
||
36 | .buf rb 16384 ; all I/O operations use this buffer |
||
37 | .basesize = $ |
||
38 | .linedata_start: |
||
39 | end virtual |
||
40 | |||
41 | virtual at 0 |
||
42 | editor_line: |
||
43 | .block dd ? |
||
44 | .offs dw ? |
||
45 | ;.length dd ? |
||
46 | .plugdata: |
||
47 | end virtual |
||
48 | |||
49 | ; when a file is loaded into the editor, this file is fragmented to blocks |
||
50 | ; each block has RESERVE_IN_BLOCK empty bytes to allow quick inserting |
||
51 | ; must be dword-aligned! |
||
52 | edit.RESERVE_IN_BLOCK = 16 |
||
53 | edit.eol_dos = 1 ; DOS/Win EOLn style (0D 0A) |
||
54 | edit.eol_unix = 2 ; Unix EOLn style (0A) |
||
55 | edit.eol_mac = 3 ; MacOS EOLn style (0D) |
||
56 | |||
57 | virtual at 0 |
||
58 | edit_block_header: |
||
59 | .next dd ? |
||
60 | .prev dd ? |
||
61 | .limit dd ? |
||
62 | .size = $ ; must be dword-aligned |
||
63 | end virtual |
||
64 | |||
65 | edit_file: |
||
66 | mov eax, [ebp + panel1_files - panel1_data] |
||
67 | mov ecx, [eax+ecx*4] |
||
68 | test byte [ecx], 10h |
||
69 | jz .file |
||
70 | ret |
||
71 | .file: |
||
72 | ; calculate required memory size |
||
73 | cmp dword [ecx+36], 0 |
||
74 | jnz .nomemory |
||
75 | ; block size = 4096 |
||
76 | ; block header: edit_block_header.size bytes |
||
77 | ; some plugin-specific data can follow |
||
78 | ; reserve RESERVE_IN_BLOCK free bytes in the end of block |
||
79 | mov ebx, 4096 |
||
80 | mov eax, [EditPlugInfo] |
||
81 | add eax, edit_block_header.size |
||
82 | mov [EditBlockStart], eax |
||
83 | sub ebx, eax |
||
84 | sub ebx, edit.RESERVE_IN_BLOCK |
||
85 | mov [EditBlockSize], ebx |
||
86 | ; now ebx = size of file data in each block |
||
87 | mov eax, [ecx+32] |
||
88 | ; if eax == 0, set eax = 1 |
||
89 | sub eax, 1 |
||
90 | adc eax, 1 |
||
91 | xor edx, edx |
||
92 | div ebx |
||
93 | sub edx, 1 |
||
94 | sbb eax, -1 |
||
95 | add eax, [EditDataSize] |
||
96 | ; eax = number of blocks + memory for editor_data structure |
||
97 | cmp eax, 0x80000000 shr 12 |
||
98 | jb .memok |
||
99 | .nomemory: |
||
100 | push aEditNoMemory |
||
101 | mov eax, esp |
||
102 | push ContinueBtn |
||
103 | push 1 |
||
104 | push eax |
||
105 | push 1 |
||
106 | call SayErr |
||
107 | pop eax |
||
108 | ret |
||
109 | .memok: |
||
110 | lea esi, [ebp + panel1_dir - panel1_data] |
||
111 | push eax |
||
112 | push ecx |
||
113 | mov ecx, eax |
||
114 | shl ecx, 12 |
||
115 | mov edx, editor_vtable |
||
116 | call new_screen |
||
117 | pop ecx |
||
118 | pop ebx |
||
119 | test eax, eax |
||
120 | jnz @f |
||
121 | ret |
||
122 | @@: |
||
123 | mov [ebp + editor_data.memsize], ebx |
||
124 | mov al, [EditEOLStyle] |
||
125 | mov [ebp + editor_data.eol], al |
||
126 | mov eax, [esi + panel1_hPlugin - panel1_data] |
||
127 | mov [ebp + editor_data.hPlugin], eax |
||
128 | test eax, eax |
||
129 | jz .nocopyhostname |
||
130 | lea edi, [ebp + editor_data.hostname] |
||
131 | push esi |
||
132 | mov eax, dword [esi + panel1_parents - panel1_dir] |
||
133 | mov esi, dword [esi + panel1_parents_sz - panel1_dir] |
||
134 | add esi, eax |
||
135 | @@: |
||
136 | dec esi |
||
137 | cmp byte [esi-1], 0 |
||
138 | jz @f |
||
139 | cmp byte [esi-1], '/' |
||
140 | jnz @b |
||
141 | @@: |
||
142 | lodsb |
||
143 | stosb |
||
144 | test al, al |
||
145 | jnz @b |
||
146 | pop esi |
||
147 | .nocopyhostname: |
||
148 | mov eax, dword [esi + panel1_hFile - panel1_dir] |
||
149 | mov [ebp + editor_data.hFile], eax |
||
150 | mov [ebp + editor_data.encoding], encodings.cp866 |
||
151 | xor eax, eax |
||
152 | mov [ebp + editor_data.flags], al |
||
153 | inc eax |
||
154 | mov [ebp + editor_data.numlines], eax |
||
155 | lea edi, [ebp + editor_data.filename] |
||
156 | mov ebx, readinfo |
||
157 | mov [ebx+21], edi |
||
158 | @@: |
||
159 | lodsb |
||
160 | test al, al |
||
161 | jz @f |
||
162 | stosb |
||
163 | jmp @b |
||
164 | @@: |
||
165 | lea esi, [ecx+40] |
||
166 | mov al, '/' |
||
167 | cmp byte [edi-1], al |
||
168 | jz @f |
||
169 | stosb |
||
170 | @@: |
||
171 | lodsb |
||
172 | stosb |
||
173 | test al, al |
||
174 | jnz @b |
||
175 | ; load file into memory |
||
176 | mov esi, [ebp + editor_data.memsize] |
||
177 | mov edi, [EditDataSize] |
||
178 | sub esi, edi ; esi = number of blocks |
||
179 | shl edi, 12 |
||
180 | ;mov [ebp + editor_data.curpos_block], edi |
||
181 | mov [ebp + editor_data.first_block], edi |
||
182 | mov [ebp + editor_data.cur_block], edi |
||
183 | add edi, ebp ; edi -> first block |
||
184 | mov [ebp + editor_data.linedata_start + editor_line.block], edi |
||
185 | xor eax, eax |
||
186 | mov [ebx+4], eax |
||
187 | mov [ebx+8], eax |
||
188 | mov dword [ebx+12], 16384 |
||
189 | lea eax, [ebp + editor_data.buf] |
||
190 | mov [ebx+16], eax |
||
191 | mov edx, [ebp + editor_data.hPlugin] |
||
192 | test edx, edx |
||
193 | jz @f |
||
194 | pushad |
||
195 | push O_READ |
||
196 | push dword [ebx+21] |
||
197 | push [ebp + editor_data.hFile] |
||
198 | call [edx + PluginInfo.open] |
||
199 | popad |
||
200 | test eax, eax |
||
201 | jz ..openerr_in_screen |
||
202 | mov ebx, eax |
||
203 | @@: |
||
204 | .readloop: |
||
205 | mov edx, [ebp + editor_data.hPlugin] |
||
206 | test edx, edx |
||
207 | jz .readnative |
||
208 | pushad |
||
209 | push 16384 |
||
210 | push [readinfo.data] |
||
211 | push ebx |
||
212 | call [edx + PluginInfo.read] |
||
213 | popad |
||
214 | cmp eax, -1 |
||
215 | jnz .readok |
||
216 | ; let us hope that plugin says error itself |
||
217 | push ebp |
||
218 | push ebx |
||
219 | call [edx + PluginInfo.close] |
||
220 | pop ebp |
||
221 | jmp .readfailed |
||
222 | .readnative: |
||
223 | push ebx |
||
224 | push 70 |
||
225 | pop eax |
||
226 | int 40h |
||
227 | mov edx, ebx |
||
228 | xchg eax, edx |
||
229 | pop ebx |
||
230 | add dword [ebx+4], eax |
||
231 | adc dword [ebx+8], 0 |
||
232 | test edx, edx |
||
233 | jz .readok |
||
234 | cmp edx, 6 |
||
235 | jz .readok |
||
236 | push dword [ebx+21] |
||
237 | push aCannotReadFile |
||
238 | xchg eax, edx |
||
239 | call get_error_msg |
||
240 | push eax |
||
241 | mov eax, esp |
||
242 | push RetryOrCancelBtn |
||
243 | push 2 |
||
244 | push eax |
||
245 | push 3 |
||
246 | call SayErr |
||
247 | add esp, 3*4 |
||
248 | test eax, eax |
||
249 | jz .readnative |
||
250 | .readfailed: |
||
251 | jmp delete_active_screen |
||
252 | .readok: |
||
253 | ; eax = number of bytes read |
||
254 | test eax, eax |
||
255 | jnz @f |
||
256 | mov ecx, edi |
||
257 | sub ecx, ebp |
||
258 | cmp ecx, [ebp + editor_data.first_block] |
||
259 | jnz .readdone |
||
260 | @@: |
||
261 | push eax ebx |
||
262 | mov ebx, [ebx+16] |
||
263 | .loadloop: |
||
264 | mov ecx, [EditBlockSize] |
||
265 | cmp eax, ecx |
||
266 | ja @f |
||
267 | mov ecx, eax |
||
268 | @@: |
||
269 | sub eax, ecx |
||
270 | push eax |
||
271 | dec esi |
||
272 | jns .hasblock |
||
273 | push ecx |
||
274 | add [ebp + editor_data.memsize], 8 |
||
275 | add esi, 8 |
||
276 | mov ecx, [ebp + editor_data.memsize] |
||
277 | cmp ecx, 80000000h shr 12 |
||
278 | jb @f |
||
279 | .nomemory2: |
||
280 | pop ecx eax ebx eax |
||
281 | call .nomemory |
||
282 | jmp .readfailed |
||
283 | @@: |
||
284 | sub edi, ebp |
||
285 | shl ecx, 12 |
||
286 | mov edx, ebp |
||
287 | call xpgrealloc |
||
288 | test eax, eax |
||
289 | jz .nomemory2 |
||
290 | mov ebp, eax |
||
291 | add edi, eax |
||
292 | pop ecx |
||
293 | .hasblock: |
||
294 | lea eax, [edi + 0x1000] |
||
295 | push eax |
||
296 | sub eax, ebp |
||
297 | stosd ; edit_block_header.next |
||
298 | sub eax, 0x2000 |
||
299 | stosd ; edit_block_header.prev |
||
300 | mov eax, [EditBlockStart] |
||
301 | add eax, ecx |
||
302 | stosd ; edit_block_header.limit |
||
303 | push ecx |
||
304 | mov ecx, [EditPlugInfo] |
||
305 | inc ecx |
||
306 | jz @f |
||
307 | dec ecx |
||
308 | @@: |
||
309 | xor eax, eax |
||
310 | rep stosb ; info for plugins: zeroed |
||
311 | pop ecx |
||
312 | push esi edi ecx |
||
313 | mov esi, ebx |
||
314 | add ecx, 3 |
||
315 | shr ecx, 2 |
||
316 | rep movsd |
||
317 | mov ebx, esi |
||
318 | pop ecx edi |
||
319 | ; calculate number of lines in this block |
||
320 | mov esi, edi |
||
321 | xor edx, edx |
||
322 | test ecx, ecx |
||
323 | jz .4 |
||
324 | .1: |
||
325 | lodsb |
||
326 | cmp al, 13 |
||
327 | jz @f |
||
328 | cmp al, 10 |
||
329 | jz @f |
||
330 | mov dl, 0 |
||
331 | jmp .3 |
||
332 | @@: |
||
333 | cmp al, dl |
||
334 | mov dl, 0 |
||
335 | jz .3 |
||
336 | inc [ebp + editor_data.numlines] |
||
337 | cmp al, 10 |
||
338 | jz .3 |
||
339 | mov dl, 10 |
||
340 | .3: |
||
341 | loop .1 |
||
342 | .4: |
||
343 | pop esi |
||
344 | pop edi |
||
345 | pop eax |
||
346 | test eax, eax |
||
347 | jnz .loadloop |
||
348 | pop ebx eax |
||
349 | cmp eax, 16384 |
||
350 | jz .readloop |
||
351 | .readdone: |
||
352 | xor eax, eax |
||
353 | mov ecx, edi |
||
354 | sub ecx, ebp |
||
355 | mov edx, ecx |
||
356 | shr ecx, 12 |
||
357 | sub ecx, [ebp + editor_data.memsize] |
||
358 | neg ecx |
||
359 | mov [ebp + editor_data.numfree], ecx |
||
360 | jz .nofree |
||
361 | mov [ebp + editor_data.freeblocks], edx |
||
362 | push edi |
||
363 | .addfree: |
||
364 | add edx, 1000h |
||
365 | mov [edi], edx |
||
366 | add edi, 1000h |
||
367 | loop .addfree |
||
368 | mov [edi-1000h], eax |
||
369 | pop edi |
||
370 | .nofree: |
||
371 | sub edi, 1000h |
||
372 | mov [edi + edit_block_header.next], eax |
||
373 | sub edi, ebp |
||
374 | mov [ebp + editor_data.last_block], edi |
||
375 | mov ecx, [EditDataSize] |
||
376 | shl ecx, 12 |
||
377 | mov [ecx + ebp + edit_block_header.prev], eax |
||
378 | mov [ebp + editor_data.curline], eax |
||
379 | mov [ebp + editor_data.curcol], eax |
||
380 | mov [ebp + editor_data.cursor_x], eax |
||
381 | inc eax |
||
382 | mov [ebp + editor_data.cursor_y], eax |
||
383 | mov eax, [EditBlockStart] |
||
384 | ;mov [ebp + editor_data.curpos_offs], eax |
||
385 | mov [ebp + editor_data.linedata_start + editor_line.offs], ax |
||
386 | mov [ebp + editor_data.cur_offs], eax |
||
387 | mov ecx, [ebp + editor_data.first_block] |
||
388 | cmp [ecx + edit_block_header.limit], eax |
||
389 | setz cl |
||
390 | movzx ecx, cl |
||
391 | dec ecx |
||
392 | mov [ebp + editor_data.cur_delta], ecx |
||
393 | call editor_init_lines |
||
394 | editor_OnRedraw: |
||
395 | mov eax, [ebp + editor_data.cursor_x] |
||
396 | mov [cursor_x], eax |
||
397 | mov eax, [ebp + editor_data.cursor_y] |
||
398 | mov [cursor_y], eax |
||
399 | test [ebp + editor_data.flags], 10h |
||
400 | jz @f |
||
401 | mov [cursor_size], cursor_big_size |
||
402 | @@: |
||
403 | call editor_test_cursor_x |
||
404 | call editor_test_cursor_y |
||
405 | call editor_set_keybar |
||
406 | call editor_draw_text |
||
407 | ret |
||
408 | |||
409 | editor_save: |
||
410 | cmp [ebp + editor_data.hPlugin], 0 |
||
411 | jz .native |
||
412 | push aCannotSaveToPlugin |
||
413 | mov eax, esp |
||
414 | push ContinueBtn |
||
415 | push 1 |
||
416 | push eax |
||
417 | push 1 |
||
418 | call SayErr |
||
419 | pop eax |
||
420 | ret |
||
421 | .native: |
||
422 | call editor_calc_filesize |
||
423 | mov ebx, writeinfo |
||
424 | mov [ebx+4], eax |
||
425 | xor eax, eax |
||
426 | mov [ebx+8], eax |
||
427 | mov [ebx+12], eax |
||
428 | mov [ebx+16], eax |
||
429 | lea eax, [ebp + editor_data.filename] |
||
430 | mov [ebx+21], eax |
||
431 | .setsize_retry: |
||
432 | mov byte [ebx], 4 |
||
433 | push 70 |
||
434 | pop eax |
||
435 | push ebx |
||
436 | int 0x40 |
||
437 | pop ebx |
||
438 | mov byte [ebx], 3 |
||
439 | test eax, eax |
||
440 | jz .sizeok |
||
441 | push dword [ebx+21] |
||
442 | push aCannotWriteFile |
||
443 | call get_error_msg |
||
444 | push eax |
||
445 | mov eax, esp |
||
446 | push RetryOrCancelBtn |
||
447 | push 2 |
||
448 | push eax |
||
449 | push 3 |
||
450 | call SayErr |
||
451 | add esp, 12 |
||
452 | test eax, eax |
||
453 | jz .setsize_retry |
||
454 | .ret: |
||
455 | ret |
||
456 | .sizeok: |
||
457 | and dword [ebx+4], 0 |
||
458 | mov esi, [ebp + editor_data.first_block] |
||
459 | add esi, ebp |
||
460 | mov ebx, [EditBlockStart] |
||
461 | call editor_normalize_offs |
||
462 | jnc .writeok |
||
463 | lea edi, [ebp + editor_data.buf] |
||
464 | .loop: |
||
465 | mov ecx, 16384 |
||
466 | call editor_get_data |
||
467 | test eax, eax |
||
468 | jz .done |
||
469 | push ebx |
||
470 | mov ebx, writeinfo |
||
471 | mov [ebx+12], eax |
||
472 | mov [ebx+16], edi |
||
473 | .write_retry: |
||
474 | push 70 |
||
475 | pop eax |
||
476 | push ebx |
||
477 | int 0x40 |
||
478 | pop ebx |
||
479 | test eax, eax |
||
480 | jz .writeok |
||
481 | push dword [ebx+21] |
||
482 | push aCannotWriteFile |
||
483 | call get_error_msg |
||
484 | push eax |
||
485 | mov eax, esp |
||
486 | push RetryOrCancelBtn |
||
487 | push 2 |
||
488 | push eax |
||
489 | push 3 |
||
490 | call SayErr |
||
491 | add esp, 12 |
||
492 | test eax, eax |
||
493 | jz .write_retry |
||
494 | ret |
||
495 | .writeok: |
||
496 | mov eax, [ebx+12] |
||
497 | add [ebx+4], eax |
||
498 | adc dword [ebx+8], 0 |
||
499 | pop ebx |
||
500 | jmp .loop |
||
501 | .done: |
||
502 | and [ebp + editor_data.flags], not 0x80 |
||
503 | ret |
||
504 | |||
505 | editor_calc_filesize: |
||
506 | xor eax, eax |
||
507 | push esi |
||
508 | mov esi, [ebp + editor_data.first_block] |
||
509 | @@: |
||
510 | add esi, ebp |
||
511 | add eax, [esi + edit_block_header.limit] |
||
512 | sub eax, [EditBlockStart] |
||
513 | mov esi, [esi + edit_block_header.next] |
||
514 | test esi, esi |
||
515 | jnz @b |
||
516 | pop ebx |
||
517 | ret |
||
518 | |||
519 | editor_get_data: |
||
520 | push edi |
||
521 | test esi, esi |
||
522 | jz .ret |
||
523 | .loop: |
||
524 | mov edx, [esi + edit_block_header.limit] |
||
525 | sub edx, ebx |
||
526 | push ecx |
||
527 | cmp ecx, edx |
||
528 | jb @f |
||
529 | mov ecx, edx |
||
530 | @@: |
||
531 | push esi |
||
532 | add esi, ebx |
||
533 | add ebx, ecx |
||
534 | add eax, ecx |
||
535 | rep movsb |
||
536 | pop esi |
||
537 | pop ecx |
||
538 | sub ecx, edx |
||
539 | jb .ret |
||
540 | mov esi, [esi + edit_block_header.next] |
||
541 | mov ebx, [EditBlockStart] |
||
542 | test esi, esi |
||
543 | jz .ret |
||
544 | add esi, ebp |
||
545 | jmp .loop |
||
546 | .ret: |
||
547 | mov eax, edi |
||
548 | pop edi |
||
549 | sub eax, edi |
||
550 | ret |
||
551 | |||
552 | editor_get_pos: |
||
553 | ;mov esi, [ebp + editor_data.curpos_block] |
||
554 | ;mov ebx, [ebp + editor_data.curpos_offs] |
||
555 | mov esi, [ebp + editor_data.linedata_start + editor_line.block] |
||
556 | sub esi, ebp |
||
557 | movzx ebx, [ebp + editor_data.linedata_start + editor_line.offs] |
||
558 | @@: |
||
559 | test esi, esi |
||
560 | jz @f |
||
561 | add esi, ebp |
||
562 | cmp ebx, [esi + edit_block_header.limit] |
||
563 | jb @f |
||
564 | mov esi, [esi + edit_block_header.next] |
||
565 | mov ebx, [EditBlockStart] |
||
566 | jmp @b |
||
567 | @@: |
||
568 | ret |
||
569 | |||
570 | editor_curline_start: |
||
571 | mov edx, [EditPlugInfo] |
||
572 | add edx, editor_line.plugdata |
||
573 | mov eax, [ebp + editor_data.cursor_y] |
||
574 | dec eax |
||
575 | imul eax, edx |
||
576 | lea edi, [ebp + eax + editor_data.linedata_start] |
||
577 | mov esi, [edi + editor_line.block] |
||
578 | movzx ebx, [edi + editor_line.offs] |
||
579 | ret |
||
580 | |||
581 | editor_step_forward: |
||
582 | ; in: esi = block (must be nonzero), ebx = offset in block |
||
583 | ; out: esi = block (zero iff EOF reached), ebx = offset in block |
||
584 | ; out: CF=1 iff EOF NOT reached |
||
585 | inc ebx |
||
586 | editor_normalize_offs: |
||
587 | cmp ebx, [esi + edit_block_header.limit] |
||
588 | jb @f |
||
589 | mov esi, [esi + edit_block_header.next] |
||
590 | mov ebx, [EditBlockStart] |
||
591 | test esi, esi |
||
592 | jz @f |
||
593 | add esi, ebp |
||
594 | stc |
||
595 | @@: |
||
596 | ret |
||
597 | |||
598 | editor_step_backward: |
||
599 | ; in: esi = block (must be nonzero), ebx = offset in block |
||
600 | ; out: esi = block (zero iff input was at the beginning), ebx = offset in block |
||
601 | ; out: CF=1 iff start of file reached |
||
602 | dec ebx |
||
603 | cmp ebx, [EditBlockStart] |
||
604 | jae @f |
||
605 | mov esi, [esi + edit_block_header.prev] |
||
606 | test esi, esi |
||
607 | stc |
||
608 | jz @f |
||
609 | add esi, ebp |
||
610 | mov ebx, [esi + edit_block_header.limit] |
||
611 | dec ebx |
||
612 | @@: |
||
613 | ret |
||
614 | |||
615 | editor_get_string: |
||
616 | ; read string up to the end of line |
||
617 | ; in: esi = block, ebx = offset in block |
||
618 | ; in: edi = destination, ecx = maximum number of bytes to copy, edx = number of bytes to skip |
||
619 | ; out: esi = block, ebx = offset in block |
||
620 | ; out: ecx = number of rest bytes (ecx_in - ecx_out = number of copied characters) |
||
621 | mov ah, [edit_normal_color] |
||
622 | cmp ebx, [esi + edit_block_header.limit] |
||
623 | jz .retnp |
||
624 | push 0 ; current position in line |
||
625 | .loop: |
||
626 | test ecx, ecx |
||
627 | jz .ret |
||
628 | mov al, [esi + ebx] |
||
629 | cmp al, 13 |
||
630 | jz .ret |
||
631 | cmp al, 10 |
||
632 | jz .ret |
||
633 | cmp al, 9 |
||
634 | jz .tab |
||
635 | inc dword [esp] |
||
636 | dec edx |
||
637 | jns .4 |
||
638 | xor edx, edx |
||
639 | stosw |
||
640 | dec ecx |
||
641 | .4: |
||
642 | call editor_step_forward |
||
643 | jc .loop |
||
644 | .ret: |
||
645 | pop edx |
||
646 | .retnp: |
||
647 | ret |
||
648 | .tab: |
||
649 | push eax edx |
||
650 | mov eax, [esp+8] |
||
651 | xor edx, edx |
||
652 | div [editor_tabsize] |
||
653 | sub edx, [editor_tabsize] |
||
654 | neg edx |
||
655 | add [esp+8], edx |
||
656 | sub [esp], edx |
||
657 | pop edx eax |
||
658 | jns .4 |
||
659 | mov al, ' ' |
||
660 | @@: |
||
661 | stosw |
||
662 | dec ecx |
||
663 | jz .ret |
||
664 | inc edx |
||
665 | jnz @b |
||
666 | jmp .4 |
||
667 | |||
668 | editor_find_newline: |
||
669 | ; in: esi = block, ebx = offset in block |
||
670 | ; out: esi = block, ebx = offset in block, ecx = line length |
||
671 | xor ecx, ecx |
||
672 | test esi, esi |
||
673 | jz .ret0 |
||
674 | cmp ebx, [esi + edit_block_header.limit] |
||
675 | jb .1 |
||
676 | xor esi, esi |
||
677 | .ret0: |
||
678 | ret |
||
679 | .1: |
||
680 | mov al, [esi + ebx] |
||
681 | inc ecx |
||
682 | call editor_step_forward |
||
683 | cmp al, 13 |
||
684 | jz .2 |
||
685 | cmp al, 10 |
||
686 | jz .2 |
||
687 | test esi, esi |
||
688 | jnz .1 |
||
689 | .ret1: |
||
690 | mov esi, [ebp + editor_data.last_block] |
||
691 | add esi, ebp |
||
692 | mov ebx, [esi + edit_block_header.limit] |
||
693 | ret |
||
694 | .2: |
||
695 | dec ecx |
||
696 | test esi, esi |
||
697 | jz .ret1 |
||
698 | cmp al, 13 |
||
699 | jnz .ret |
||
700 | cmp byte [esi + ebx], 10 |
||
701 | jnz .ret |
||
702 | call editor_step_forward |
||
703 | jnc .ret1 |
||
704 | .ret: |
||
705 | ret |
||
706 | |||
707 | editor_prev_newline: |
||
708 | xor ecx, ecx |
||
709 | test esi, esi |
||
710 | jnz @f |
||
711 | mov esi, [ebp + editor_data.last_block] |
||
712 | add esi, ebp |
||
713 | mov ebx, [esi + edit_block_header.limit] |
||
714 | @@: |
||
715 | call editor_step_backward |
||
716 | jc .ret |
||
717 | mov al, [esi + ebx] |
||
718 | call editor_step_backward |
||
719 | jc .ret |
||
720 | cmp al, 10 |
||
721 | jnz .1 |
||
722 | cmp byte [esi + ebx], 13 |
||
723 | jnz .1 |
||
724 | @@: |
||
725 | call editor_step_backward |
||
726 | jc .ret |
||
727 | .1: |
||
728 | inc ecx |
||
729 | mov al, [esi + ebx] |
||
730 | cmp al, 13 |
||
731 | jz @f |
||
732 | cmp al, 10 |
||
733 | jnz @b |
||
734 | @@: |
||
735 | dec ecx |
||
736 | inc ebx |
||
737 | cmp ebx, [esi + edit_block_header.limit] |
||
738 | jb .ret |
||
739 | mov esi, [esi + edit_block_header.next] |
||
740 | mov ebx, [EditBlockStart] |
||
741 | test esi, esi |
||
742 | jz .ret |
||
743 | add esi, ebp |
||
744 | .ret: |
||
745 | test esi, esi |
||
746 | jnz @f |
||
747 | mov esi, [ebp + editor_data.first_block] |
||
748 | mov ebx, [EditBlockStart] |
||
749 | add esi, ebp |
||
750 | @@: |
||
751 | ret |
||
752 | |||
753 | editor_init_lines: |
||
754 | call editor_get_pos |
||
755 | test esi, esi |
||
756 | jnz @f |
||
757 | mov esi, [ebp + editor_data.last_block] |
||
758 | add esi, ebp |
||
759 | mov ebx, [esi + edit_block_header.limit] |
||
760 | @@: |
||
761 | mov ecx, max_height |
||
762 | lea edi, [ebp + editor_data.linedata_start] |
||
763 | .1: |
||
764 | mov eax, esi |
||
765 | stosd ; editor_line.block |
||
766 | mov eax, ebx |
||
767 | stosw ; editor_line.offs |
||
768 | push ecx |
||
769 | call editor_find_newline |
||
770 | ;mov eax, ecx |
||
771 | ;stosd ; editor_line.length |
||
772 | xor eax, eax |
||
773 | mov ecx, [EditPlugInfo] |
||
774 | rep stosb |
||
775 | pop ecx |
||
776 | loop .1 |
||
777 | ret |
||
778 | |||
779 | editor_draw_status: |
||
780 | lea edi, [ebp + editor_data.buf] |
||
781 | mov ah, [edit_status_color] |
||
782 | mov ecx, [cur_width] |
||
783 | sub ecx, 56 |
||
784 | cmp ecx, 25 |
||
785 | jge @f |
||
786 | push 25 |
||
787 | pop ecx |
||
788 | @@: |
||
789 | call viewedit_draw_filename |
||
790 | inc ecx |
||
791 | rep stosw |
||
792 | test [ebp + editor_data.flags], 80h |
||
793 | jz @f |
||
794 | mov al, '*' |
||
795 | @@: |
||
796 | stosw |
||
797 | mov al, ' ' |
||
798 | test [ebp + editor_data.flags], 40h |
||
799 | jz @f |
||
800 | mov al, '-' |
||
801 | @@: |
||
802 | stosw |
||
803 | mov al, ' ' |
||
804 | test [ebp + editor_data.flags], 20h |
||
805 | jz @f |
||
806 | mov al, '"' |
||
807 | @@: |
||
808 | stosw |
||
809 | mov al, ' ' |
||
810 | mov cl, 10 |
||
811 | rep stosw |
||
812 | movzx esi, [ebp+editor_data.encoding] |
||
813 | lea esi, [encodings.names+esi*8] |
||
814 | push edi esi |
||
815 | dec edi |
||
816 | dec edi |
||
817 | std |
||
818 | add esi, 8 |
||
819 | @@: |
||
820 | dec esi |
||
821 | cmp byte [esi], ' ' |
||
822 | jz @b |
||
823 | @@: |
||
824 | lodsb |
||
825 | stosw |
||
826 | cmp esi, [esp] |
||
827 | jae @b |
||
828 | cld |
||
829 | pop esi edi |
||
830 | mov esi, aLine |
||
831 | mov cl, 8 |
||
832 | @@: |
||
833 | lodsb |
||
834 | stosw |
||
835 | loop @b |
||
836 | mov cl, 13 |
||
837 | mov al, ' ' |
||
838 | rep stosw |
||
839 | std |
||
840 | push edi |
||
841 | dec edi |
||
842 | dec edi |
||
843 | push eax |
||
844 | mov eax, [ebp + editor_data.numlines] |
||
845 | mov cl, 10 |
||
846 | @@: |
||
847 | xor edx, edx |
||
848 | div ecx |
||
849 | xchg eax, edx |
||
850 | add al, '0' |
||
851 | mov ah, [edit_status_color] |
||
852 | stosw |
||
853 | xchg eax, edx |
||
854 | test eax, eax |
||
855 | jnz @b |
||
856 | mov al, '/' |
||
857 | mov ah, [edit_status_color] |
||
858 | stosw |
||
859 | mov eax, [ebp + editor_data.curline] |
||
860 | add eax, [ebp + editor_data.cursor_y] |
||
861 | @@: |
||
862 | xor edx, edx |
||
863 | div ecx |
||
864 | xchg eax, edx |
||
865 | add al, '0' |
||
866 | mov ah, [edit_status_color] |
||
867 | stosw |
||
868 | xchg eax, edx |
||
869 | test eax, eax |
||
870 | jnz @b |
||
871 | pop eax |
||
872 | stosw |
||
873 | cld |
||
874 | pop edi |
||
875 | mov ah, [edit_status_color] |
||
876 | mov esi, aCol |
||
877 | mov cl, 7 |
||
878 | @@: |
||
879 | lodsb |
||
880 | stosw |
||
881 | loop @b |
||
882 | mov eax, [ebp + editor_data.curcol] |
||
883 | add eax, [ebp + editor_data.cursor_x] |
||
884 | inc eax |
||
885 | mov cl, 10 |
||
886 | push -'0' |
||
887 | @@: |
||
888 | xor edx, edx |
||
889 | div ecx |
||
890 | push edx |
||
891 | test eax, eax |
||
892 | jnz @b |
||
893 | @@: |
||
894 | pop eax |
||
895 | mov ah, [edit_status_color] |
||
896 | add al, '0' |
||
897 | jz @f |
||
898 | stosw |
||
899 | jmp @b |
||
900 | @@: |
||
901 | mov al, ' ' |
||
902 | mov cl, 13 |
||
903 | rep stosw |
||
904 | xor eax, eax |
||
905 | xor edx, edx |
||
906 | call get_console_ptr |
||
907 | lea esi, [ebp + editor_data.buf] |
||
908 | mov ecx, [cur_width] |
||
909 | shr ecx, 1 |
||
910 | rep movsd |
||
911 | adc ecx, ecx |
||
912 | rep movsw |
||
913 | cmp [ebp + editor_data.cur_delta], -1 |
||
914 | jnz .a |
||
915 | mov al, ' ' |
||
916 | mov byte [edi-4*2], al |
||
917 | mov byte [edi-3*2], al |
||
918 | mov byte [edi-2*2], al |
||
919 | mov byte [edi-1*2], al |
||
920 | mov eax, [ebp + editor_data.cur_block] |
||
921 | add eax, ebp |
||
922 | add eax, [ebp + editor_data.cur_offs] |
||
923 | movzx eax, byte [eax] |
||
924 | mov cl, 100 |
||
925 | ;xor edx, edx ; edx=0 already |
||
926 | div ecx |
||
927 | test al, al |
||
928 | jz @f |
||
929 | add al, '0' |
||
930 | mov [edi-3*2], al |
||
931 | @@: |
||
932 | xchg eax, edx |
||
933 | aam |
||
934 | test ah, ah |
||
935 | jnz .b |
||
936 | cmp byte [edi-3*2], ' ' |
||
937 | jz @f |
||
938 | .b: |
||
939 | add ah, '0' |
||
940 | mov [edi-2*2], ah |
||
941 | @@: |
||
942 | add al, '0' |
||
943 | mov [edi-1*2], al |
||
944 | .a: |
||
945 | ret |
||
946 | |||
947 | editor_draw_line: |
||
948 | push ecx |
||
949 | mov ecx, [cur_width] |
||
950 | test esi, esi |
||
951 | jz .2 |
||
952 | lea edi, [ebp + editor_data.buf] |
||
953 | push edx edi |
||
954 | mov edx, [ebp + editor_data.curcol] |
||
955 | call editor_get_string |
||
956 | mov al, ' ' |
||
957 | rep stosw |
||
958 | pop esi edx |
||
959 | xor eax, eax |
||
960 | call get_console_ptr |
||
961 | mov ecx, [cur_width] |
||
962 | shr ecx, 1 |
||
963 | rep movsd |
||
964 | adc ecx, ecx |
||
965 | rep movsw |
||
966 | pop ecx |
||
967 | ret |
||
968 | .2: |
||
969 | xor eax, eax |
||
970 | call get_console_ptr |
||
971 | mov al, ' ' |
||
972 | mov ah, [edit_normal_color] |
||
973 | rep stosw |
||
974 | pop ecx |
||
975 | ret |
||
976 | |||
977 | editor_draw_text: |
||
978 | call editor_draw_status |
||
979 | push 1 |
||
980 | pop edx |
||
981 | lea ecx, [ebp + editor_data.linedata_start] |
||
982 | .1: |
||
983 | mov esi, [ecx + editor_line.block] |
||
984 | movzx ebx, [ecx + editor_line.offs] |
||
985 | add ecx, editor_line.plugdata |
||
986 | add ecx, [EditPlugInfo] |
||
987 | call editor_draw_line |
||
988 | inc edx |
||
989 | mov eax, [cur_height] |
||
990 | dec eax |
||
991 | cmp edx, eax |
||
992 | jb .1 |
||
993 | jmp draw_image |
||
994 | |||
995 | editor_set_keybar: |
||
996 | mov eax, keybar_editor |
||
997 | movzx esi, [ebp+editor_data.encoding] |
||
998 | dec esi |
||
999 | jz @f |
||
1000 | push 1 |
||
1001 | pop esi |
||
1002 | @@: |
||
1003 | lea esi, [encodings.names+esi*8] |
||
1004 | lea edi, [eax+keybar_cp2-keybar_editor] |
||
1005 | movsd |
||
1006 | movsw |
||
1007 | jmp draw_keybar |
||
1008 | |||
1009 | editor_up_scroll: |
||
1010 | push ecx |
||
1011 | sub [ebp + editor_data.curline], ecx |
||
1012 | mov edx, [EditPlugInfo] |
||
1013 | add edx, editor_line.plugdata |
||
1014 | imul eax, edx, max_height |
||
1015 | imul ecx, edx |
||
1016 | sub ecx, eax |
||
1017 | neg ecx |
||
1018 | lea esi, [ebp + ecx + editor_data.linedata_start - 4] |
||
1019 | lea edi, [ebp + eax + editor_data.linedata_start - 4] |
||
1020 | shr ecx, 2 |
||
1021 | std |
||
1022 | rep movsd |
||
1023 | cld |
||
1024 | jnc @f |
||
1025 | mov cx, [esi+2] |
||
1026 | mov [edi+2], cx |
||
1027 | sub edi, 2 |
||
1028 | @@: |
||
1029 | pop ecx |
||
1030 | add edi, 4 |
||
1031 | movzx ebx, [edi + editor_line.offs] |
||
1032 | mov esi, [edi + editor_line.block] |
||
1033 | @@: |
||
1034 | push ecx |
||
1035 | call editor_prev_newline |
||
1036 | sub edi, edx |
||
1037 | push edi |
||
1038 | mov eax, esi |
||
1039 | stosd ; editor_line.offs |
||
1040 | mov eax, ebx |
||
1041 | stosw ; editor_line.block |
||
1042 | ;mov eax, ecx |
||
1043 | ;stosd ; editor_line.length |
||
1044 | mov ecx, [EditPlugInfo] |
||
1045 | xor eax, eax |
||
1046 | rep stosb |
||
1047 | pop edi |
||
1048 | pop ecx |
||
1049 | loop @b |
||
1050 | ; fall through to editor_update_cur |
||
1051 | |||
1052 | editor_update_cur: |
||
1053 | mov ecx, [ebp + editor_data.cursor_x] |
||
1054 | add ecx, [ebp + editor_data.curcol] |
||
1055 | call editor_curline_start |
||
1056 | xor edx, edx ; current position in the line |
||
1057 | cmp ebx, [esi + edit_block_header.limit] |
||
1058 | jz .notfound |
||
1059 | .scan: |
||
1060 | mov al, [esi+ebx] |
||
1061 | cmp al, 13 |
||
1062 | jz .notfound |
||
1063 | cmp al, 10 |
||
1064 | jz .notfound |
||
1065 | test ecx, ecx |
||
1066 | jz .found |
||
1067 | cmp al, 9 |
||
1068 | jz .tab |
||
1069 | inc edx |
||
1070 | dec ecx |
||
1071 | call editor_step_forward |
||
1072 | jc .scan |
||
1073 | .notfound: |
||
1074 | test esi, esi |
||
1075 | jnz @f |
||
1076 | mov esi, [ebp + editor_data.last_block] |
||
1077 | add esi, ebp |
||
1078 | mov ebx, [esi + edit_block_header.limit] |
||
1079 | @@: |
||
1080 | mov [ebp + editor_data.cur_delta], ecx |
||
1081 | xor eax, eax |
||
1082 | jmp .reta |
||
1083 | .found: |
||
1084 | xor eax, eax |
||
1085 | .founda: |
||
1086 | or [ebp + editor_data.cur_delta], -1 |
||
1087 | .reta: |
||
1088 | sub esi, ebp |
||
1089 | mov [ebp + editor_data.cur_block], esi |
||
1090 | mov [ebp + editor_data.cur_offs], ebx |
||
1091 | ret |
||
1092 | .tab: |
||
1093 | push edx |
||
1094 | mov eax, edx |
||
1095 | xor edx, edx |
||
1096 | div [editor_tabsize] |
||
1097 | sub edx, [editor_tabsize] |
||
1098 | neg edx |
||
1099 | add [esp], edx |
||
1100 | cmp ecx, edx |
||
1101 | jb .curintab |
||
1102 | sub ecx, edx |
||
1103 | pop edx |
||
1104 | call editor_step_forward |
||
1105 | jnc .notfound |
||
1106 | test ecx, ecx |
||
1107 | jz .found |
||
1108 | jmp .scan |
||
1109 | .curintab: |
||
1110 | sub [esp], edx |
||
1111 | pop edx |
||
1112 | cmp edx, [ebp + editor_data.curcol] |
||
1113 | setc al |
||
1114 | jae @f |
||
1115 | mov [ebp + editor_data.curcol], edx |
||
1116 | @@: |
||
1117 | sub edx, [ebp + editor_data.curcol] |
||
1118 | mov [ebp + editor_data.cursor_x], edx |
||
1119 | mov [cursor_x], edx |
||
1120 | jmp .founda |
||
1121 | |||
1122 | editor_down_scroll: |
||
1123 | push ecx |
||
1124 | lea edi, [ebp + editor_data.linedata_start] |
||
1125 | mov edx, [EditPlugInfo] |
||
1126 | add edx, editor_line.plugdata |
||
1127 | imul ecx, edx |
||
1128 | lea esi, [edi + ecx] |
||
1129 | imul eax, edx, max_height |
||
1130 | sub eax, ecx |
||
1131 | mov ecx, eax |
||
1132 | shr ecx, 2 |
||
1133 | rep movsd |
||
1134 | adc ecx, ecx |
||
1135 | rep movsw |
||
1136 | @@: |
||
1137 | mov esi, edi |
||
1138 | sub esi, edx |
||
1139 | movzx ebx, [esi + editor_line.offs] |
||
1140 | mov esi, [esi + editor_line.block] |
||
1141 | pop ecx |
||
1142 | jecxz .ret |
||
1143 | @@: |
||
1144 | push ecx |
||
1145 | call editor_find_newline |
||
1146 | mov eax, esi |
||
1147 | stosd ; editor_line.block |
||
1148 | mov eax, ebx |
||
1149 | stosw ; editor_line.offs |
||
1150 | ;mov eax, ecx |
||
1151 | ;stosd ; editor_line.length |
||
1152 | mov ecx, [EditPlugInfo] |
||
1153 | xor eax, eax |
||
1154 | rep stosb |
||
1155 | pop ecx |
||
1156 | loop @b |
||
1157 | .ret: |
||
1158 | ret |
||
1159 | |||
1160 | editor_end_scroll: |
||
1161 | call editor_curline_start |
||
1162 | ; calculate visible length of the line (it differs from the real length if tabulations are present) |
||
1163 | xor ecx, ecx |
||
1164 | cmp ebx, [esi + edit_block_header.limit] |
||
1165 | jz .calcdone |
||
1166 | .calcloop: |
||
1167 | mov al, [esi+ebx] |
||
1168 | cmp al, 10 |
||
1169 | jz .calcdone |
||
1170 | cmp al, 13 |
||
1171 | jz .calcdone |
||
1172 | cmp al, 9 |
||
1173 | jz .calctab |
||
1174 | inc ecx |
||
1175 | .calcnext: |
||
1176 | call editor_step_forward |
||
1177 | jc .calcloop |
||
1178 | jmp .calcdone |
||
1179 | .calctab: |
||
1180 | mov eax, ecx |
||
1181 | xor edx, edx |
||
1182 | div [editor_tabsize] |
||
1183 | sub edx, [editor_tabsize] |
||
1184 | sub ecx, edx |
||
1185 | jmp .calcnext |
||
1186 | .calcdone: |
||
1187 | test esi, esi |
||
1188 | jnz @f |
||
1189 | mov esi, [ebp + editor_data.last_block] |
||
1190 | add esi, ebp |
||
1191 | mov ebx, [esi + edit_block_header.limit] |
||
1192 | @@: |
||
1193 | sub esi, ebp |
||
1194 | mov [ebp + editor_data.cur_block], esi |
||
1195 | mov [ebp + editor_data.cur_offs], ebx |
||
1196 | and [ebp + editor_data.cur_delta], 0 |
||
1197 | ; ecx = number of symbols in the line |
||
1198 | ; calculate new position of view range |
||
1199 | mov eax, [ebp + editor_data.curcol] |
||
1200 | cmp ecx, eax |
||
1201 | jb .toleft |
||
1202 | add eax, [cur_width] |
||
1203 | cmp ecx, eax |
||
1204 | jae .toright |
||
1205 | sub ecx, [ebp + editor_data.curcol] |
||
1206 | mov [ebp + editor_data.cursor_x], ecx |
||
1207 | mov [cursor_x], ecx |
||
1208 | ret |
||
1209 | .toleft: |
||
1210 | mov [ebp + editor_data.curcol], ecx |
||
1211 | and [ebp + editor_data.cursor_x], 0 |
||
1212 | and [cursor_x], 0 |
||
1213 | stc |
||
1214 | ret |
||
1215 | .toright: |
||
1216 | mov eax, [cur_width] |
||
1217 | dec eax |
||
1218 | sub ecx, eax |
||
1219 | mov [ebp + editor_data.curcol], ecx |
||
1220 | mov [ebp + editor_data.cursor_x], eax |
||
1221 | mov [cursor_x], eax |
||
1222 | stc |
||
1223 | ret |
||
1224 | |||
1225 | editor_move_linestart: |
||
1226 | ; in: esi = block, ebx = start offset, ecx = delta |
||
1227 | lea edi, [ebp + editor_data.linedata_start] |
||
1228 | mov edx, max_height |
||
1229 | .0: |
||
1230 | cmp [edi + editor_line.block], esi |
||
1231 | jnz .1 |
||
1232 | movzx eax, [edi + editor_line.offs] |
||
1233 | cmp eax, ebx |
||
1234 | ja .2 |
||
1235 | ; push eax |
||
1236 | ; add eax, [edi + editor_line.length] |
||
1237 | ; cmp eax, ebx |
||
1238 | ; jb @f |
||
1239 | ; add [edi + editor_line.length], ecx |
||
1240 | ;@@: |
||
1241 | ; pop eax |
||
1242 | cmp eax, [esi + edit_block_header.limit] |
||
1243 | jb .1 |
||
1244 | push esi ebx |
||
1245 | mov ebx, eax |
||
1246 | jmp .3 |
||
1247 | .2: |
||
1248 | push esi ebx |
||
1249 | mov ebx, eax |
||
1250 | add ebx, ecx |
||
1251 | .3: |
||
1252 | cmp ebx, [esi + edit_block_header.limit] |
||
1253 | jb .4 |
||
1254 | cmp [esi + edit_block_header.next], 0 |
||
1255 | jz .4 |
||
1256 | sub ebx, [esi + edit_block_header.limit] |
||
1257 | mov esi, [esi + edit_block_header.next] |
||
1258 | add esi, ebp |
||
1259 | add ebx, [EditBlockStart] |
||
1260 | jmp .3 |
||
1261 | .4: |
||
1262 | mov [edi + editor_line.block], esi |
||
1263 | mov [edi + editor_line.offs], bx |
||
1264 | pop ebx esi |
||
1265 | .1: |
||
1266 | add edi, editor_line.plugdata |
||
1267 | add edi, [EditPlugInfo] |
||
1268 | dec edx |
||
1269 | jnz .0 |
||
1270 | ;lea edx, [ebp + editor_data.curpos_block] |
||
1271 | ;call .5 |
||
1272 | ;add edx, editor_data.cur_block - editor_data.curpos_block |
||
1273 | lea edx, [ebp + editor_data.cur_block] |
||
1274 | ; call .5 |
||
1275 | ; ret |
||
1276 | .5: |
||
1277 | mov eax, [edx] |
||
1278 | add eax, ebp |
||
1279 | cmp eax, esi |
||
1280 | jnz .6 |
||
1281 | cmp [edx+4], ebx |
||
1282 | jbe @f |
||
1283 | add [edx+4], ecx |
||
1284 | @@: |
||
1285 | mov eax, [edx+4] |
||
1286 | sub eax, [esi + edit_block_header.limit] |
||
1287 | jb .6 |
||
1288 | push ecx |
||
1289 | mov ecx, [esi + edit_block_header.next] |
||
1290 | add ecx, ebp |
||
1291 | add eax, [EditBlockStart] |
||
1292 | mov [edx], ecx |
||
1293 | mov [edx+4], eax |
||
1294 | pop ecx |
||
1295 | .6: |
||
1296 | ret |
||
1297 | |||
1298 | editor_reserve_symbol: |
||
1299 | push 1 |
||
1300 | pop ecx |
||
1301 | |||
1302 | editor_reserve_space: |
||
1303 | ; ‚áâ ¢«ï¥â ¯ãá⮥ ¬¥áâ® ¢ãâàì 楯®çª¨ ¡«®ª®¢ |
||
1304 | ; in: ecx = number of symbols to add, esi = block, ebx = offset |
||
1305 | mov eax, [esi + edit_block_header.limit] |
||
1306 | add eax, ecx |
||
1307 | cmp eax, 4096 |
||
1308 | ja .add |
||
1309 | mov [esi + edit_block_header.limit], eax |
||
1310 | push esi ecx |
||
1311 | sub eax, ecx |
||
1312 | lea esi, [esi + eax - 1] |
||
1313 | lea edi, [esi + ecx] |
||
1314 | sub eax, ebx |
||
1315 | mov ecx, eax |
||
1316 | std |
||
1317 | rep movsb |
||
1318 | cld |
||
1319 | pop ecx esi |
||
1320 | call editor_move_linestart |
||
1321 | clc |
||
1322 | ret |
||
1323 | .add: |
||
1324 | push ecx |
||
1325 | mov eax, [esi + edit_block_header.limit] |
||
1326 | sub eax, [EditBlockStart] |
||
1327 | add eax, ecx |
||
1328 | push eax |
||
1329 | xor edx, edx |
||
1330 | div [EditBlockSize] |
||
1331 | push eax |
||
1332 | sub eax, [ebp + editor_data.numfree] |
||
1333 | jbe .norealloc |
||
1334 | mov edx, [ebp + editor_data.memsize] |
||
1335 | push eax edx |
||
1336 | add eax, edx |
||
1337 | mov ecx, eax |
||
1338 | shl ecx, 12 |
||
1339 | mov edx, ebp |
||
1340 | call xpgrealloc |
||
1341 | pop edx ecx |
||
1342 | test eax, eax |
||
1343 | jz .nomem |
||
1344 | add [ebp + editor_data.memsize], ecx |
||
1345 | sub eax, ebp |
||
1346 | add ebp, eax |
||
1347 | add esi, eax |
||
1348 | push ecx |
||
1349 | mov ecx, max_height |
||
1350 | lea edi, [ebp + editor_data.linedata_start] |
||
1351 | @@: |
||
1352 | add [edi + editor_line.block], eax |
||
1353 | add edi, editor_line.plugdata |
||
1354 | add edi, [EditPlugInfo] |
||
1355 | loop @b |
||
1356 | pop ecx |
||
1357 | shl edx, 12 |
||
1358 | add [ebp + editor_data.numfree], ecx |
||
1359 | lea edi, [edx + ebp] |
||
1360 | mov eax, [ebp + editor_data.freeblocks] |
||
1361 | mov [ebp + editor_data.freeblocks], edx |
||
1362 | @@: |
||
1363 | add edx, 1000h |
||
1364 | mov [edi], edx |
||
1365 | add edi, 1000h |
||
1366 | loop @b |
||
1367 | mov [edi-1000h], eax |
||
1368 | .norealloc: |
||
1369 | pop edx |
||
1370 | push [esi + edit_block_header.next] |
||
1371 | push esi |
||
1372 | sub [ebp + editor_data.numfree], edx |
||
1373 | mov edi, [ebp + editor_data.freeblocks] |
||
1374 | @@: |
||
1375 | mov [esi + edit_block_header.next], edi |
||
1376 | add edi, ebp |
||
1377 | push edi |
||
1378 | push dword [edi] |
||
1379 | stosd ; edit_block_header.next - will be filled later |
||
1380 | mov eax, esi |
||
1381 | sub eax, ebp |
||
1382 | stosd ; edit_block_header.prev |
||
1383 | mov eax, 4096 - edit.RESERVE_IN_BLOCK |
||
1384 | stosd ; edit_block_header.limit |
||
1385 | mov eax, [EditBlockSize] |
||
1386 | sub [esp+16], eax |
||
1387 | xor eax, eax |
||
1388 | mov ecx, [EditPlugInfo] |
||
1389 | rep stosb |
||
1390 | pop edi |
||
1391 | pop esi |
||
1392 | dec edx |
||
1393 | jnz @b |
||
1394 | mov [ebp + editor_data.freeblocks], edi |
||
1395 | mov edi, esi |
||
1396 | pop esi |
||
1397 | pop [edi + edit_block_header.next] |
||
1398 | pop ecx |
||
1399 | add ecx, [EditBlockSize] |
||
1400 | mov edx, ecx |
||
1401 | shr edx, 1;2 |
||
1402 | mov eax, ecx |
||
1403 | sub eax, edx |
||
1404 | cmp eax, [EditBlockSize] |
||
1405 | jb @f |
||
1406 | mov eax, [EditBlockSize] |
||
1407 | mov edx, ecx |
||
1408 | sub edx, eax |
||
1409 | @@: |
||
1410 | add eax, [EditBlockStart] |
||
1411 | add edx, [EditBlockStart] |
||
1412 | mov ecx, [esi + edit_block_header.limit] |
||
1413 | mov [esi + edit_block_header.limit], eax |
||
1414 | mov [edi + edit_block_header.limit], edx |
||
1415 | sub ecx, ebx |
||
1416 | push ecx |
||
1417 | push esi edi ecx |
||
1418 | add esi, ecx |
||
1419 | add esi, ebx |
||
1420 | push edx |
||
1421 | sub edx, [EditBlockStart] |
||
1422 | cmp ecx, edx |
||
1423 | jb @f |
||
1424 | mov ecx, edx |
||
1425 | @@: |
||
1426 | pop edx |
||
1427 | sub [esp], ecx |
||
1428 | add edi, edx |
||
1429 | sub esi, ecx |
||
1430 | sub edi, ecx |
||
1431 | rep movsb |
||
1432 | pop ecx edi esi |
||
1433 | push esi edi |
||
1434 | lea edi, [esi + eax - 1] |
||
1435 | add esi, ebx |
||
1436 | lea esi, [esi + ecx - 1] |
||
1437 | std |
||
1438 | rep movsb |
||
1439 | cld |
||
1440 | pop edi esi |
||
1441 | pop ecx |
||
1442 | mov ecx, ebx |
||
1443 | sub ecx, eax |
||
1444 | jb @f |
||
1445 | push esi edi |
||
1446 | add esi, eax |
||
1447 | add edi, [EditBlockStart] |
||
1448 | rep movsb |
||
1449 | pop edi esi |
||
1450 | @@: |
||
1451 | push esi edi |
||
1452 | sub esi, ebp |
||
1453 | sub edi, ebp |
||
1454 | cmp [ebp + editor_data.last_block], esi |
||
1455 | jnz @f |
||
1456 | mov [ebp + editor_data.last_block], edi |
||
1457 | @@: |
||
1458 | pop edi esi |
||
1459 | pop ecx |
||
1460 | call editor_move_linestart |
||
1461 | cmp ebx, [esi + edit_block_header.limit] |
||
1462 | jb @f |
||
1463 | sub ebx, [esi + edit_block_header.limit] |
||
1464 | mov esi, [esi + edit_block_header.next] |
||
1465 | add esi, ebp |
||
1466 | add ebx, [EditBlockStart] |
||
1467 | @@: |
||
1468 | clc |
||
1469 | ret |
||
1470 | .nomem: |
||
1471 | pop eax |
||
1472 | pop ecx |
||
1473 | pop ecx |
||
1474 | add esi, ebp |
||
1475 | stc |
||
1476 | ret |
||
1477 | |||
1478 | editor_delete_symbol: |
||
1479 | push 1 |
||
1480 | pop ecx |
||
1481 | |||
1482 | editor_delete_space: |
||
1483 | ; “¤ «ï¥â ecx ¡ ©â ¨§ ⥪áâ , ç¨ ï á esi:ebx |
||
1484 | ; ecx, esi, ebx à §àãè îâáï |
||
1485 | mov eax, [esi + edit_block_header.limit] |
||
1486 | sub eax, ebx |
||
1487 | cmp eax, ecx |
||
1488 | jb .more1 |
||
1489 | push esi |
||
1490 | sub [esi + edit_block_header.limit], ecx |
||
1491 | sub eax, ecx |
||
1492 | lea edi, [esi+ebx] |
||
1493 | lea esi, [edi+ecx] |
||
1494 | mov ecx, eax |
||
1495 | rep movsb |
||
1496 | pop esi |
||
1497 | .done: |
||
1498 | call .collapse_prev |
||
1499 | call .collapse_next |
||
1500 | call editor_init_lines |
||
1501 | jmp editor_update_cur |
||
1502 | .more1: |
||
1503 | mov [esi + edit_block_header.limit], ebx |
||
1504 | sub ecx, eax |
||
1505 | @@: |
||
1506 | mov esi, [esi + edit_block_header.next] |
||
1507 | add esi, ebp |
||
1508 | mov eax, [esi + edit_block_header.limit] |
||
1509 | sub eax, [EditBlockStart] |
||
1510 | sub ecx, eax |
||
1511 | jb @f |
||
1512 | call .delete_block |
||
1513 | jmp @b |
||
1514 | @@: |
||
1515 | add ecx, eax |
||
1516 | push esi |
||
1517 | mov eax, [esi + edit_block_header.limit] |
||
1518 | sub [esi + edit_block_header.limit], ecx |
||
1519 | add eax, esi |
||
1520 | add esi, [EditBlockStart] |
||
1521 | mov edi, esi |
||
1522 | add esi, ecx |
||
1523 | sub eax, esi |
||
1524 | mov ecx, esi |
||
1525 | rep movsb |
||
1526 | pop esi |
||
1527 | call .collapse_next |
||
1528 | mov esi, [esi + edit_block_header.prev] |
||
1529 | add esi, ebp |
||
1530 | jmp .done |
||
1531 | |||
1532 | .delete_block: |
||
1533 | mov eax, [esi + edit_block_header.next] |
||
1534 | mov edx, [esi + edit_block_header.prev] |
||
1535 | test eax, eax |
||
1536 | jz .dbfirst |
||
1537 | mov [eax + ebp + edit_block_header.prev], edx |
||
1538 | jmp @f |
||
1539 | .dbfirst: |
||
1540 | mov [ebp + editor_data.first_block], edx |
||
1541 | @@: |
||
1542 | test edx, edx |
||
1543 | jz .dblast |
||
1544 | mov [edx + ebp + edit_block_header.next], eax |
||
1545 | jmp @f |
||
1546 | .dblast: |
||
1547 | mov [ebp + editor_data.last_block], eax |
||
1548 | @@: |
||
1549 | mov eax, [ebp + editor_data.freeblocks] |
||
1550 | mov [esi], eax |
||
1551 | sub esi, ebp |
||
1552 | mov [ebp + editor_data.freeblocks], esi |
||
1553 | inc [ebp + editor_data.numfree] |
||
1554 | ret |
||
1555 | |||
1556 | .collapse_prev: |
||
1557 | mov eax, [esi + edit_block_header.prev] |
||
1558 | test eax, eax |
||
1559 | jz .cpno |
||
1560 | add eax, ebp |
||
1561 | mov edx, [esi + edit_block_header.limit] |
||
1562 | sub edx, [EditBlockStart] |
||
1563 | add edx, [eax + edit_block_header.limit] |
||
1564 | cmp edx, 4096 - edit.RESERVE_IN_BLOCK |
||
1565 | ja .cpno |
||
1566 | mov edi, eax |
||
1567 | .collapse: ; (edi) + (esi) -> (edi) |
||
1568 | push edi |
||
1569 | push esi |
||
1570 | mov ecx, [esi + edit_block_header.limit] |
||
1571 | sub ecx, [EditBlockStart] |
||
1572 | add esi, [EditBlockStart] |
||
1573 | mov eax, [edi + edit_block_header.limit] |
||
1574 | add [edi + edit_block_header.limit], ecx |
||
1575 | add edi, eax |
||
1576 | rep movsb |
||
1577 | pop esi |
||
1578 | call .delete_block |
||
1579 | pop esi |
||
1580 | .cpno: |
||
1581 | ret |
||
1582 | .collapse_next: |
||
1583 | mov eax, [esi + edit_block_header.next] |
||
1584 | test eax, eax |
||
1585 | jz .cpno |
||
1586 | add eax, ebp |
||
1587 | mov edx, [esi + edit_block_header.limit] |
||
1588 | sub edx, [EditBlockStart] |
||
1589 | add edx, [eax + edit_block_header.limit] |
||
1590 | cmp edx, 4096 - edit.RESERVE_IN_BLOCK |
||
1591 | ja .cpno |
||
1592 | mov edi, esi |
||
1593 | mov esi, eax |
||
1594 | jmp .collapse |
||
1595 | |||
1596 | editor_OnKey: |
||
1597 | test al, 80h |
||
1598 | jnz .ret |
||
1599 | test [ebp + editor_data.flags], 20h |
||
1600 | jnz .symbol |
||
1601 | mov esi, editor_ctrlkeys |
||
1602 | call process_ctrl_keys |
||
1603 | jnc .ret |
||
1604 | .symbol: |
||
1605 | and [ebp + editor_data.flags], not 20h |
||
1606 | test [ebp + editor_data.flags], 40h |
||
1607 | jnz .ret |
||
1608 | or [ebp + editor_data.flags], 80h |
||
1609 | movzx eax, al |
||
1610 | call get_ascii_char |
||
1611 | mov esi, [ebp + editor_data.cur_block] |
||
1612 | add esi, ebp |
||
1613 | mov ebx, [ebp + editor_data.cur_offs] |
||
1614 | cmp al, 10 |
||
1615 | jz .insert_newline |
||
1616 | cmp al, 13 |
||
1617 | jz .insert_newline |
||
1618 | cmp [ebp + editor_data.cur_delta], -1 |
||
1619 | jnz .insert_after_eol |
||
1620 | test [ebp + editor_data.flags], 10h |
||
1621 | jnz .replace_symbol |
||
1622 | push eax |
||
1623 | call editor_reserve_symbol |
||
1624 | pop eax |
||
1625 | jc .ret |
||
1626 | .replace_symbol: |
||
1627 | cmp ebx, [esi + edit_block_header.limit] |
||
1628 | jnz @f |
||
1629 | mov esi, [esi + edit_block_header.next] |
||
1630 | add esi, ebp |
||
1631 | mov ebx, [EditBlockStart] |
||
1632 | @@: |
||
1633 | mov [esi + ebx], al |
||
1634 | .symb_inserted: |
||
1635 | call .redraw_curline |
||
1636 | jmp .right |
||
1637 | .redraw_curline: |
||
1638 | call editor_curline_start |
||
1639 | mov edx, [cursor_y] |
||
1640 | call editor_draw_line |
||
1641 | .ret: |
||
1642 | ret |
||
1643 | .insert_after_eol: |
||
1644 | mov ecx, [ebp + editor_data.cur_delta] |
||
1645 | inc ecx |
||
1646 | push eax |
||
1647 | call editor_reserve_space |
||
1648 | pop eax |
||
1649 | jc .ret |
||
1650 | push eax |
||
1651 | mov edx, ecx |
||
1652 | .2: |
||
1653 | mov ecx, [esi + edit_block_header.limit] |
||
1654 | sub ecx, ebx |
||
1655 | lea edi, [esi + ebx] |
||
1656 | cmp ecx, edx |
||
1657 | jb @f |
||
1658 | mov ecx, edx |
||
1659 | @@: |
||
1660 | add ebx, ecx |
||
1661 | sub edx, ecx |
||
1662 | mov al, ' ' |
||
1663 | rep stosb |
||
1664 | jz @f |
||
1665 | mov esi, [esi + edit_block_header.next] |
||
1666 | add esi, ebp |
||
1667 | mov ebx, [EditBlockStart] |
||
1668 | jmp .2 |
||
1669 | @@: |
||
1670 | pop eax |
||
1671 | mov [edi-1], al |
||
1672 | dec ebx |
||
1673 | sub esi, ebp |
||
1674 | mov [ebp + editor_data.cur_block], esi |
||
1675 | mov [ebp + editor_data.cur_offs], ebx |
||
1676 | or [ebp + editor_data.cur_delta], -1 |
||
1677 | jmp .symb_inserted |
||
1678 | .insert_newline: |
||
1679 | push 1 |
||
1680 | pop ecx |
||
1681 | cmp [ebp + editor_data.eol], 2 |
||
1682 | adc ecx, 0 |
||
1683 | call editor_reserve_space |
||
1684 | jc .ret |
||
1685 | ; à®áâ® â ª ¢áâ ¢«ïâì ᨬ¢®« ®¢®© áâப¨ çॢ â® - ¨§-§ áãé¥á⢮¢ ¨ï ¤¢ãå¡ ©â®¢ëå ª®¬¡¨ 権 ¯¥à¥¢®¤ áâப¨ |
||
1686 | ; áâ àë© á¨¬¢®« ¬®¦¥â ᫨âìáï á ®¢ë¬. ‚ â ª®¬ á«ãç ¥ ¯à¨¤ñâáï § ¨¬ âìáï ª®à४â¨à®¢ª®©. |
||
1687 | ; ஡«¥¬ ¡ë¢ ¥â ¢ ¤¢ãå á«ãç ïå: |
||
1688 | ; ¥á«¨ । ªâ®à áâ஥ Unix-áâ¨«ì ¨ ®¢ë© ¯¥à¥¢®¤ áâப¨ ¢áâ ¢«ï¥âáï ¥¯®á।á⢥® ¯®á«¥ |
||
1689 | ; ¯¥à¥¢®¤ áâப¨ ¢ Mac-á⨫¥; |
||
1690 | ; ¥á«¨ । ªâ®à áâ஥ Mac-áâ¨«ì ¨ ®¢ë© ¯¥à¥¢®¤ áâப¨ ¢áâ ¢«ï¥âáï ¥¯®á।á⢥® ¯¥à¥¤ |
||
1691 | ; ¯¥à¥¢®¤®¬ áâப¨ ¢ Unix-á⨫¥. |
||
1692 | ; ‚ íâ¨å á«ãç ïå ä®àá¨à㥬 ¯¥à¥¢®¤ áâப¨ ¢ ⥪ã饬 á⨫¥ ä ©« . |
||
1693 | mov al, [ebp + editor_data.eol] |
||
1694 | cmp al, edit.eol_dos |
||
1695 | jz .insert_eol_dos |
||
1696 | cmp al, edit.eol_mac |
||
1697 | jz .insert_eol_mac |
||
1698 | mov al, 10 ; Unix-style for end-of-line |
||
1699 | push esi ebx |
||
1700 | call editor_step_backward |
||
1701 | jc @f |
||
1702 | cmp byte [esi+ebx], 13 |
||
1703 | jnz @f |
||
1704 | mov al, 13 ; force Mac-style to avoid collapse |
||
1705 | @@: |
||
1706 | pop ebx esi |
||
1707 | mov [esi+ebx], al |
||
1708 | jmp .eol_correct |
||
1709 | .insert_eol_mac: |
||
1710 | mov al, 13 ; Mac-style for end-of-line |
||
1711 | push esi ebx |
||
1712 | call editor_step_forward |
||
1713 | jnc @f |
||
1714 | cmp byte [esi+ebx], 10 |
||
1715 | jnz @f |
||
1716 | mov al, 10 ; force Unix-style to avoid collapse |
||
1717 | @@: |
||
1718 | pop ebx esi |
||
1719 | mov [esi+ebx], al |
||
1720 | jmp .eol_correct |
||
1721 | .insert_eol_dos: |
||
1722 | mov byte [esi+ebx], 13 |
||
1723 | call editor_step_forward |
||
1724 | mov byte [esi+ebx], 10 |
||
1725 | .eol_correct: |
||
1726 | call editor_step_forward |
||
1727 | test esi, esi |
||
1728 | jnz @f |
||
1729 | mov esi, [ebp + editor_data.last_block] |
||
1730 | add esi, ebp |
||
1731 | mov ebx, [esi + edit_block_header.limit] |
||
1732 | @@: |
||
1733 | and [ebp + editor_data.cur_delta], 0 |
||
1734 | cmp ebx, [esi + edit_block_header.limit] |
||
1735 | jz @f |
||
1736 | mov al, [esi+ebx] |
||
1737 | cmp al, 10 |
||
1738 | jz @f |
||
1739 | cmp al, 13 |
||
1740 | jz @f |
||
1741 | dec [ebp + editor_data.cur_delta] |
||
1742 | @@: |
||
1743 | ; ã çâ® ¦¥, ¢ ⥪áâ ã¦ë¥ ᨬ¢®«ë ¢áâ ¢¨«¨, ⥯¥àì ¤® ᪮à४â¨à®¢ âì ¨ä®à¬ æ¨î ® ç «¥ áâப íªà ¥ |
||
1744 | mov edi, [ebp + editor_data.cursor_y] |
||
1745 | mov ecx, max_height-1 |
||
1746 | sub ecx, edi |
||
1747 | dec edi |
||
1748 | mov eax, [EditPlugInfo] |
||
1749 | add eax, editor_line.plugdata |
||
1750 | imul edi, eax, max_height |
||
1751 | imul ecx, eax |
||
1752 | lea edi, [ebp + edi + editor_data.linedata_start - 2] |
||
1753 | push esi |
||
1754 | mov esi, edi |
||
1755 | sub esi, eax |
||
1756 | shr ecx, 1 |
||
1757 | std |
||
1758 | rep movsw |
||
1759 | cld |
||
1760 | pop esi |
||
1761 | add edi, 2 |
||
1762 | sub edi, eax |
||
1763 | push esi |
||
1764 | mov esi, edi |
||
1765 | sub esi, eax |
||
1766 | pop eax |
||
1767 | stosd ; editor_line.block |
||
1768 | sub eax, ebp |
||
1769 | mov [ebp + editor_data.cur_block], eax |
||
1770 | mov eax, ebx |
||
1771 | stosw ; editor_line.offs |
||
1772 | mov [ebp + editor_data.cur_offs], eax |
||
1773 | ;mov eax, ecx |
||
1774 | ;stosd ; editor_line.length |
||
1775 | mov ecx, [EditPlugInfo] |
||
1776 | xor eax, eax |
||
1777 | rep stosb |
||
1778 | ; ®¤ã áâபã áâ «® ¡®«ìè¥ |
||
1779 | inc [ebp + editor_data.numlines] |
||
1780 | ; ªãàá®à ®ª ¦¥âáï ¢ ç «¥ áâப¨ |
||
1781 | mov [ebp + editor_data.cursor_x], eax |
||
1782 | mov [ebp + editor_data.curcol], eax |
||
1783 | mov [cursor_x], eax |
||
1784 | ; ¨ ¯¥à¥¤¢¨¥âáï áâப㠨¦¥ |
||
1785 | mov eax, [ebp + editor_data.cursor_y] |
||
1786 | inc eax |
||
1787 | mov edx, [cur_height] |
||
1788 | dec edx |
||
1789 | cmp eax, edx |
||
1790 | jae .down_scroll |
||
1791 | mov [ebp + editor_data.cursor_y], eax |
||
1792 | mov [cursor_y], eax |
||
1793 | jmp editor_draw_text |
||
1794 | |||
1795 | .exit_confirm: |
||
1796 | test [ebp + editor_data.flags], 80h |
||
1797 | jz .exit |
||
1798 | push aFileModified |
||
1799 | mov eax, esp |
||
1800 | push EditorExitBtn |
||
1801 | push 3 |
||
1802 | push eax |
||
1803 | push 1 |
||
1804 | push aEditorTitle |
||
1805 | call SayErrTitle |
||
1806 | pop ecx |
||
1807 | test eax, eax |
||
1808 | jz .save |
||
1809 | dec eax |
||
1810 | jz .exit |
||
1811 | ret |
||
1812 | .exit_save: |
||
1813 | test [ebp + editor_data.flags], 80h |
||
1814 | jz .exit |
||
1815 | .save: |
||
1816 | call editor_save |
||
1817 | .exit: |
||
1818 | call editor_OnExit |
||
1819 | jmp delete_active_screen |
||
1820 | .f2: |
||
1821 | call editor_save |
||
1822 | jmp .redraw_status |
||
1823 | |||
1824 | .up_scroll: |
||
1825 | cmp [ebp + editor_data.curline], 0 |
||
1826 | jz .ret |
||
1827 | push 1 |
||
1828 | pop ecx |
||
1829 | call editor_up_scroll |
||
1830 | jmp editor_draw_text |
||
1831 | .up: |
||
1832 | mov eax, [ebp + editor_data.cursor_y] |
||
1833 | dec eax |
||
1834 | jz .up_scroll |
||
1835 | .set_cursor_y: |
||
1836 | mov [ebp + editor_data.cursor_y], eax |
||
1837 | mov [cursor_y], eax |
||
1838 | call editor_update_cur |
||
1839 | test al, al |
||
1840 | jnz editor_draw_text |
||
1841 | .redraw_status: |
||
1842 | call editor_draw_status |
||
1843 | jmp draw_image |
||
1844 | .down: |
||
1845 | mov eax, [ebp + editor_data.cursor_y] |
||
1846 | inc eax |
||
1847 | push eax |
||
1848 | add eax, [ebp + editor_data.curline] |
||
1849 | cmp eax, [ebp + editor_data.numlines] |
||
1850 | pop eax |
||
1851 | ja .ret |
||
1852 | mov edx, [cur_height] |
||
1853 | dec edx |
||
1854 | cmp eax, edx |
||
1855 | jnz .set_cursor_y |
||
1856 | .down_scroll: |
||
1857 | inc [ebp + editor_data.curline] |
||
1858 | lea edi, [ebp + editor_data.linedata_start] |
||
1859 | mov eax, [EditPlugInfo] |
||
1860 | add eax, editor_line.plugdata |
||
1861 | lea esi, [edi + eax] |
||
1862 | imul ecx, eax, max_height-1 |
||
1863 | shr ecx, 2 |
||
1864 | rep movsd |
||
1865 | adc ecx, ecx |
||
1866 | rep movsw |
||
1867 | sub esi, eax |
||
1868 | sub esi, eax |
||
1869 | movzx ebx, [esi + editor_line.offs] |
||
1870 | mov esi, [esi + editor_line.block] |
||
1871 | call editor_find_newline |
||
1872 | mov eax, esi |
||
1873 | stosd ; editor_line.block |
||
1874 | mov eax, ebx |
||
1875 | stosw ; editor_line.offs |
||
1876 | ;mov eax, ecx |
||
1877 | ;stosd ; editor_line.length |
||
1878 | mov ecx, [EditPlugInfo] |
||
1879 | xor eax, eax |
||
1880 | rep stosb |
||
1881 | jmp .ret2 |
||
1882 | |||
1883 | .pgup: |
||
1884 | mov ecx, [cur_height] |
||
1885 | sub ecx, 3 |
||
1886 | mov edx, [ebp + editor_data.curline] |
||
1887 | mov eax, edx |
||
1888 | push edx |
||
1889 | sub edx, ecx |
||
1890 | jnc @f |
||
1891 | xor edx, edx |
||
1892 | @@: |
||
1893 | mov [ebp + editor_data.curline], edx |
||
1894 | add eax, [ebp + editor_data.cursor_y] |
||
1895 | dec eax |
||
1896 | sub eax, ecx |
||
1897 | jnc @f |
||
1898 | xor eax, eax |
||
1899 | @@: |
||
1900 | sub eax, edx |
||
1901 | inc eax |
||
1902 | mov [ebp + editor_data.cursor_y], eax |
||
1903 | mov [cursor_y], eax |
||
1904 | pop ecx |
||
1905 | sub ecx, edx |
||
1906 | push ecx |
||
1907 | mov edx, [EditPlugInfo] |
||
1908 | add edx, editor_line.plugdata |
||
1909 | imul ecx, edx |
||
1910 | imul eax, edx, max_height |
||
1911 | lea edi, [ebp + editor_data.linedata_start + eax - 2] |
||
1912 | mov esi, edi |
||
1913 | sub esi, ecx |
||
1914 | sub eax, ecx |
||
1915 | mov ecx, eax |
||
1916 | shr ecx, 1 |
||
1917 | std |
||
1918 | rep movsw |
||
1919 | cld |
||
1920 | pop ecx |
||
1921 | jecxz .ret2 |
||
1922 | inc edi |
||
1923 | inc edi |
||
1924 | mov esi, [edi + editor_line.block] |
||
1925 | movzx ebx, [edi + editor_line.offs] |
||
1926 | @@: |
||
1927 | push ecx |
||
1928 | call editor_prev_newline |
||
1929 | sub edi, edx |
||
1930 | push edi |
||
1931 | mov eax, esi |
||
1932 | stosd ; editor_line.block |
||
1933 | mov eax, ebx |
||
1934 | stosw ; editor_line.offs |
||
1935 | ;mov eax, ecx |
||
1936 | ;stosd ; editor_line.length |
||
1937 | mov ecx, [EditPlugInfo] |
||
1938 | xor eax, eax |
||
1939 | rep stosb |
||
1940 | pop edi |
||
1941 | pop ecx |
||
1942 | loop @b |
||
1943 | .ret2: |
||
1944 | call editor_update_cur |
||
1945 | jmp editor_draw_text |
||
1946 | .pgdn: |
||
1947 | mov edx, [cur_height] |
||
1948 | sub edx, 2 |
||
1949 | mov ecx, [ebp + editor_data.curline] |
||
1950 | push ecx |
||
1951 | lea ecx, [edx + ecx - 1] |
||
1952 | mov eax, [ebp + editor_data.numlines] |
||
1953 | sub eax, edx |
||
1954 | jnc @f |
||
1955 | xor eax, eax |
||
1956 | @@: |
||
1957 | cmp ecx, eax |
||
1958 | jb @f |
||
1959 | mov ecx, eax |
||
1960 | @@: |
||
1961 | mov [ebp + editor_data.curline], ecx |
||
1962 | pop eax |
||
1963 | push eax |
||
1964 | add eax, [ebp + editor_data.cursor_y] |
||
1965 | lea eax, [eax + edx - 1] |
||
1966 | cmp eax, [ebp + editor_data.numlines] |
||
1967 | jb @f |
||
1968 | mov eax, [ebp + editor_data.numlines] |
||
1969 | @@: |
||
1970 | sub eax, ecx |
||
1971 | mov [ebp + editor_data.cursor_y], eax |
||
1972 | mov [cursor_y], eax |
||
1973 | pop edx |
||
1974 | sub ecx, edx |
||
1975 | call editor_down_scroll |
||
1976 | jmp .ret2 |
||
1977 | |||
1978 | .left: |
||
1979 | call editor_cursor_left |
||
1980 | jc .redraw_status |
||
1981 | jmp editor_draw_text |
||
1982 | .ret3: |
||
1983 | ret |
||
1984 | |||
1985 | .right: |
||
1986 | cmp [ebp + editor_data.cur_delta], -1 |
||
1987 | jz .right_in_text |
||
1988 | cmp [ebp + editor_data.curcol], 0x80000000 - 0x1000 |
||
1989 | jae .ret3 |
||
1990 | inc [ebp + editor_data.cur_delta] |
||
1991 | push 1 |
||
1992 | pop edx |
||
1993 | jmp .right_char |
||
1994 | .right_in_text: |
||
1995 | mov esi, [ebp + editor_data.cur_block] |
||
1996 | add esi, ebp |
||
1997 | mov ebx, [ebp + editor_data.cur_offs] |
||
1998 | mov al, [esi + ebx] |
||
1999 | push eax |
||
2000 | call editor_step_forward |
||
2001 | test esi, esi |
||
2002 | jz .right_eol0 |
||
2003 | mov al, [esi + ebx] |
||
2004 | cmp al, 10 |
||
2005 | jz .right_eol |
||
2006 | cmp al, 13 |
||
2007 | jz .right_eol |
||
2008 | jmp .right_ok |
||
2009 | .right_eol0: |
||
2010 | mov esi, [ebp + editor_data.last_block] |
||
2011 | add esi, ebp |
||
2012 | mov ebx, [esi + edit_block_header.limit] |
||
2013 | .right_eol: |
||
2014 | inc [ebp + editor_data.cur_delta] |
||
2015 | .right_ok: |
||
2016 | sub esi, ebp |
||
2017 | mov [ebp + editor_data.cur_block], esi |
||
2018 | mov [ebp + editor_data.cur_offs], ebx |
||
2019 | pop eax |
||
2020 | push 1 |
||
2021 | pop edx |
||
2022 | cmp al, 9 |
||
2023 | jnz .right_char |
||
2024 | mov eax, [ebp + editor_data.curcol] |
||
2025 | add eax, [ebp + editor_data.cursor_x] |
||
2026 | xor edx, edx |
||
2027 | div [editor_tabsize] |
||
2028 | sub edx, [editor_tabsize] |
||
2029 | neg edx |
||
2030 | .right_char: |
||
2031 | mov eax, [ebp + editor_data.cursor_x] |
||
2032 | add eax, edx |
||
2033 | cmp eax, [cur_width] |
||
2034 | jb .set_cursor_x |
||
2035 | add eax, [ebp + editor_data.curcol] |
||
2036 | mov edx, [cur_width] |
||
2037 | dec edx |
||
2038 | sub eax, edx |
||
2039 | mov [ebp + editor_data.cursor_x], edx |
||
2040 | mov [cursor_x], edx |
||
2041 | mov [ebp + editor_data.curcol], eax |
||
2042 | jmp editor_draw_text |
||
2043 | .set_cursor_x: |
||
2044 | mov [ebp + editor_data.cursor_x], eax |
||
2045 | mov [cursor_x], eax |
||
2046 | jmp .redraw_status |
||
2047 | |||
2048 | .home: |
||
2049 | call editor_curline_start |
||
2050 | and [ebp + editor_data.cur_delta], 0 |
||
2051 | cmp ebx, [esi + edit_block_header.limit] |
||
2052 | jz @f |
||
2053 | mov al, [esi+ebx] |
||
2054 | cmp al, 10 |
||
2055 | jz @f |
||
2056 | cmp al, 13 |
||
2057 | jz @f |
||
2058 | dec [ebp + editor_data.cur_delta] |
||
2059 | @@: |
||
2060 | sub esi, ebp |
||
2061 | mov [ebp + editor_data.cur_block], esi |
||
2062 | mov [ebp + editor_data.cur_offs], ebx |
||
2063 | xor eax, eax |
||
2064 | mov [ebp + editor_data.cursor_x], eax |
||
2065 | mov [cursor_x], eax |
||
2066 | xchg eax, [ebp + editor_data.curcol] |
||
2067 | test eax, eax |
||
2068 | jnz editor_draw_text |
||
2069 | jmp .redraw_status |
||
2070 | |||
2071 | .end: |
||
2072 | call editor_end_scroll |
||
2073 | jc editor_draw_text |
||
2074 | jmp .redraw_status |
||
2075 | |||
2076 | .ins: |
||
2077 | xor [ebp + editor_data.flags], 10h |
||
2078 | mov eax, cursor_normal_size |
||
2079 | test [ebp + editor_data.flags], 10h |
||
2080 | jz @f |
||
2081 | mov eax, cursor_big_size |
||
2082 | @@: |
||
2083 | mov [cursor_size], eax |
||
2084 | jmp draw_image |
||
2085 | |||
2086 | .backspace: |
||
2087 | cmp [ebp + editor_data.cur_delta], -1 |
||
2088 | jz @f |
||
2089 | cmp [ebp + editor_data.cur_delta], 0 |
||
2090 | jnz .left |
||
2091 | @@: |
||
2092 | test [ebp + editor_data.flags], 40h |
||
2093 | jnz .ret3 |
||
2094 | mov esi, [ebp + editor_data.cur_block] |
||
2095 | add esi, ebp |
||
2096 | mov ebx, [ebp + editor_data.cur_offs] |
||
2097 | call editor_step_backward |
||
2098 | jc .ret3 |
||
2099 | push esi ebx |
||
2100 | call editor_cursor_left |
||
2101 | pop ebx esi |
||
2102 | setc al |
||
2103 | push eax |
||
2104 | push esi ebx |
||
2105 | cmp byte [esi+ebx], 10 |
||
2106 | jnz @f |
||
2107 | call editor_step_backward |
||
2108 | jc @f |
||
2109 | cmp byte [esi+ebx], 13 |
||
2110 | jnz @f |
||
2111 | pop eax eax |
||
2112 | jmp .del_char |
||
2113 | @@: |
||
2114 | pop ebx esi |
||
2115 | jmp .del_char |
||
2116 | .del: |
||
2117 | test [ebp + editor_data.flags], 40h |
||
2118 | jnz .ret3 |
||
2119 | mov esi, [ebp + editor_data.cur_block] |
||
2120 | add esi, ebp |
||
2121 | mov ebx, [ebp + editor_data.cur_offs] |
||
2122 | call editor_normalize_offs |
||
2123 | jnc .ret3 |
||
2124 | push 0 |
||
2125 | .del_char: |
||
2126 | or [ebp + editor_data.flags], 80h |
||
2127 | mov al, [esi+ebx] |
||
2128 | push 1 |
||
2129 | pop ecx |
||
2130 | push eax |
||
2131 | push esi ebx |
||
2132 | cmp al, 13 |
||
2133 | jnz @f |
||
2134 | call editor_step_forward |
||
2135 | jnc @f |
||
2136 | cmp byte [esi+ebx], 10 |
||
2137 | jnz @f |
||
2138 | inc ecx |
||
2139 | @@: |
||
2140 | pop ebx esi |
||
2141 | call editor_delete_space |
||
2142 | pop eax |
||
2143 | cmp al, 13 |
||
2144 | jz @f |
||
2145 | cmp al, 10 |
||
2146 | jz @f |
||
2147 | pop eax |
||
2148 | test al, al |
||
2149 | jnz .del1 |
||
2150 | call .redraw_curline |
||
2151 | jmp .redraw_status |
||
2152 | @@: |
||
2153 | pop eax |
||
2154 | dec [ebp + editor_data.numlines] |
||
2155 | call editor_test_cursor_y |
||
2156 | .del1: |
||
2157 | jmp editor_draw_text |
||
2158 | |||
2159 | editor_cursor_left: |
||
2160 | cmp [ebp + editor_data.cur_delta], -1 |
||
2161 | jz .in_text |
||
2162 | dec [ebp + editor_data.cur_delta] |
||
2163 | cmp [ebp + editor_data.cur_delta], -1 |
||
2164 | jnz .left_cursor |
||
2165 | .in_text: |
||
2166 | mov esi, [ebp + editor_data.cur_block] |
||
2167 | add esi, ebp |
||
2168 | mov ebx, [ebp + editor_data.cur_offs] |
||
2169 | call editor_step_backward |
||
2170 | jc .ret_clc |
||
2171 | mov al, [esi + ebx] |
||
2172 | cmp al, 13 |
||
2173 | jz .eol |
||
2174 | cmp al, 10 |
||
2175 | jz .eol2 |
||
2176 | cmp al, 9 |
||
2177 | jz .tab |
||
2178 | sub esi, ebp |
||
2179 | mov [ebp + editor_data.cur_block], esi |
||
2180 | mov [ebp + editor_data.cur_offs], ebx |
||
2181 | .left_cursor: |
||
2182 | mov eax, [ebp + editor_data.cursor_x] |
||
2183 | test eax, eax |
||
2184 | jz @f |
||
2185 | dec eax |
||
2186 | .set_cursor_x: |
||
2187 | mov [ebp + editor_data.cursor_x], eax |
||
2188 | mov [cursor_x], eax |
||
2189 | .ret_clc: |
||
2190 | clc |
||
2191 | ret |
||
2192 | @@: |
||
2193 | dec [ebp + editor_data.curcol] |
||
2194 | jmp .ret_stc |
||
2195 | .tab: |
||
2196 | mov eax, [ebp + editor_data.cursor_x] |
||
2197 | test eax, eax |
||
2198 | jz @f |
||
2199 | dec eax |
||
2200 | mov [ebp + editor_data.cursor_x], eax |
||
2201 | mov [cursor_x], eax |
||
2202 | call editor_update_cur |
||
2203 | test al, al |
||
2204 | jz .ret_clc |
||
2205 | .ret_stc: |
||
2206 | stc |
||
2207 | ret |
||
2208 | @@: |
||
2209 | dec [ebp + editor_data.curcol] |
||
2210 | call editor_update_cur |
||
2211 | jmp .ret_stc |
||
2212 | .eol2: |
||
2213 | push esi ebx |
||
2214 | call editor_step_backward |
||
2215 | jc @f |
||
2216 | cmp byte [esi + ebx], 13 |
||
2217 | jnz @f |
||
2218 | pop eax eax |
||
2219 | push esi ebx |
||
2220 | @@: |
||
2221 | pop ebx esi |
||
2222 | .eol: |
||
2223 | mov eax, [ebp + editor_data.cursor_y] |
||
2224 | dec eax |
||
2225 | jz .scroll_left_toup |
||
2226 | push 0 ; no full redraw |
||
2227 | mov [ebp + editor_data.cursor_y], eax |
||
2228 | mov [cursor_y], eax |
||
2229 | jmp .scroll_left_toend |
||
2230 | .scroll_left_toup: |
||
2231 | push 1 |
||
2232 | pop ecx |
||
2233 | call editor_up_scroll |
||
2234 | push 1 ; full redraw required |
||
2235 | .scroll_left_toend: |
||
2236 | call editor_end_scroll |
||
2237 | pop eax |
||
2238 | adc al, 0 |
||
2239 | jnz .ret_stc |
||
2240 | jmp .ret_clc |
||
2241 | |||
2242 | editor_test_cursor_x: |
||
2243 | mov ecx, [cur_width] |
||
2244 | dec ecx |
||
2245 | mov eax, [ebp + editor_data.cursor_x] |
||
2246 | sub eax, ecx |
||
2247 | jbe @f |
||
2248 | add [ebp + editor_data.curcol], eax |
||
2249 | mov [ebp + editor_data.cursor_x], ecx |
||
2250 | mov [cursor_x], ecx |
||
2251 | @@: |
||
2252 | ret |
||
2253 | |||
2254 | editor_test_cursor_y: |
||
2255 | mov ecx, [ebp + editor_data.cursor_y] |
||
2256 | mov edx, [cur_height] |
||
2257 | dec edx |
||
2258 | dec edx |
||
2259 | sub ecx, edx |
||
2260 | ja .scroll_down |
||
2261 | mov ecx, [ebp + editor_data.curline] |
||
2262 | add ecx, edx |
||
2263 | sub ecx, [ebp + editor_data.numlines] |
||
2264 | ja .scroll_up |
||
2265 | .clc_ret: |
||
2266 | clc |
||
2267 | ret |
||
2268 | .scroll_down: |
||
2269 | add [ebp + editor_data.curline], ecx |
||
2270 | sub [ebp + editor_data.cursor_y], ecx |
||
2271 | sub [cursor_y], ecx |
||
2272 | call editor_down_scroll |
||
2273 | stc |
||
2274 | ret |
||
2275 | .scroll_up: |
||
2276 | cmp ecx, [ebp + editor_data.curline] |
||
2277 | jb @f |
||
2278 | mov ecx, [ebp + editor_data.curline] |
||
2279 | @@: |
||
2280 | jecxz .clc_ret |
||
2281 | add [ebp + editor_data.cursor_y], ecx |
||
2282 | add [cursor_y], ecx |
||
2283 | call editor_up_scroll |
||
2284 | stc |
||
2285 | ret |
||
2286 | |||
2287 | editor_OnExit: |
||
2288 | mov edx, [ebp+editor_data.hPlugin] |
||
2289 | test edx, edx |
||
2290 | jz @f |
||
2291 | mov ebx, [ebp+editor_data.hFile] |
||
2292 | call close_handle_if_unused |
||
2293 | @@: |
||
2294 | ret>>>> |