Subversion Repositories Kolibri OS

Rev

Rev 1338 | Rev 1449 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1338 IgorA 1
mouse_wnd_main:
2
  push eax ebx ecx
3
  mcall 37,2 ;get mouse buttons
4
 
5
  cmp al,1
6
  jne @f
7
    mcall 37,1 ;get mouse coords
8
    mov ebx,[wndMain.top]
9
    add ebx,[recMain.top]
10
    cmp ax,bx
11
    jl @f ;y_mouse
12
 
13
    sub ebx,[recMain.top]
14
    add ebx,[wndMain.height]
15
    cmp bx,ax
16
    jl @f ;y_mouse>y_wnd
17
 
18
    mov ebx,[wndMain.left]
19
    add ebx,[recMain.left]
20
    mov ecx,eax
21
    shr ecx,16
22
    cmp cx,bx
23
    jl @f ;x_mouse
24
 
25
    sub ebx,[recMain.left]
26
    add ebx,[wndMain.width]
27
    cmp bx,cx
28
    jl @f ;x_mouse>x_wnd
29
 
30
    call draw_cursor_sumb
31
    call wnd_main_click
32
    ;call draw_main_cursor ;???
33
    jmp .no_in_wnd
34
  @@:
35
    call wnd_main_mouse_scroll
36
    cmp [dragm],0
37
    je .no_in_wnd
38
      mov [dragm],0
39
      call draw_but_toolbar
40
      call draw_main_win
41
  .no_in_wnd:
42
  pop ecx ebx eax
43
  ret
44
 
45
; input:
46
;  eax->(x,y)
47
wnd_main_click:
48
  push ecx edx
49
 
50
  push eax
51
    shr eax,16
52
    and eax,0xffff
53
    sub eax,[wndMain.left]
54
    sub eax,[recMain.left]
55
 
56
    xor edx,edx
57
    mov ecx,[recMain.width]
58
    div cx
59
    ;inc eax
60
    cmp eax,[hScr.cur_area]
61
    jle @f
62
      mov eax,[hScr.cur_area]
63
    @@:
64
    ;dec eax
65
    mov [cur_x],eax
66
  pop eax
67
 
68
  push eax
69
    and eax,0xffff
70
    sub eax,[wndMain.top]
71
    sub eax,[recMain.top]
72
 
73
    xor edx,edx
74
    mov ecx,[recMain.height]
75
    div cx
76
    inc eax
77
    cmp eax,[wScr.cur_area]
78
    jle @f
79
      mov eax,[wScr.cur_area]
80
    @@:
81
    dec eax
82
    mov [cur_y],eax
83
  pop eax
84
 
85
  cmp [dragm],0
86
  je @f
87
    call SelMove
88
    jmp .sel_move
89
  @@:
90
    mov [dragm],1
91
    call SelStart
92
  .sel_move:
93
  pop edx ecx
94
  ret
95
 
96
wnd_main_mouse_scroll:
97
  push eax ebx
98
  mcall 37,7
99
  cmp ax,0
100
  je .no_scroll
101
    mov ebx,dword[wScr.position] ;copy old scroll position
102
    and eax,0xffff
103
    btr ax,15
104
    jae @f
105
      or eax,0xffff8000
106
    @@:
107
    add dword[wScr.position],eax
108
 
109
    mov eax,[wScr.position]
110
    cmp eax,[wScr.max_area]
111
    jb @f
112
      mov dword[wScr.position],ebx ;if scroll position out of range
113
      jmp .no_scroll
114
    @@:
115
    call draw_main_win
116
  .no_scroll:
117
  pop ebx eax
118
  ret
119
 
120
draw_but_toolbar:
121
 
122
  push ebx ecx edx
123
  mov ecx,0x40000000
124
;  mov edx,5*65536+25
125
  mov edx,85*65536+2
126
  call draw_but_icon
127
 
128
  inc cx
129
;  mov edx,30*65536+25
130
  mov edx,110*65536+2
131
  call draw_but_icon
132
 
133
call CanSave
134
cmp al,1
135
je @f
136
and ecx,0xffff
137
@@:
138
  inc cx
139
;  mov edx,55*65536+25
140
  mov edx,135*65536+2
141
  call draw_but_icon
142
or ecx,0x40000000
143
 
144
  inc cx
145
  mov edx,85*65536+25
146
  call draw_but_icon
147
 
148
call IsSel
149
cmp al,0
150
jne @f
151
and ecx,0xffff
152
@@:
153
  inc cx ; Cut
154
  mov edx,110*65536+25
155
  call draw_but_icon
156
 
157
  inc cx ; Copy
158
  mov edx,135*65536+25
159
  call draw_but_icon
160
 
161
  mov cx,10 ; Upper
162
  mov edx,265*65536+25
163
  call draw_but_icon
164
 
165
  inc cx ; Lower
166
  mov edx,290*65536+25
167
  call draw_but_icon
168
 
169
  inc cx ; Reverse
170
  mov edx,315*65536+25
171
  call draw_but_icon
172
or ecx,0x40000000
173
 
174
cmp byte[buf],0
175
jne @f
176
and ecx,0xffff
177
@@:
178
  mov cx,6 ; Paste
179
  mov edx,160*65536+25
180
  call draw_but_icon
181
or ecx,0x40000000
182
 
183
  inc cx
184
  mov edx,185*65536+25
185
  call draw_but_icon
186
 
187
  inc cx
188
  mov edx,210*65536+25
189
  call draw_but_icon
190
 
191
  inc cx
192
  mov edx,235*65536+25
193
  call draw_but_icon
194
 
195
mov ebx,[tim_Undo]
196
cmp [ch_tim],ebx
197
jg @f
198
and ecx,0xffff
199
@@:
200
  mov cx,13
201
  mov edx,345*65536+25
202
  call draw_but_icon
203
or ecx,0x40000000
204
 
205
cmp [tim_Undo],1
206
jge @f
207
and ecx,0xffff
208
@@:
209
  inc cx
210
  mov edx,370*65536+25
211
  call draw_but_icon
212
or ecx,0x40000000
213
 
214
  inc cx
215
  mov edx,400*65536+25
216
  call draw_but_icon
217
 
218
  inc cx
219
  mov edx,425*65536+25
220
  call draw_but_icon
221
 
222
  mov cx,17
223
  mov edx,450*65536+25
224
  call draw_but_icon
225
 
226
  pop edx ecx ebx
227
  ret
228
 
229
 
230
;input:
231
; ebx = x*2^16+y coords to left up point clear line
232
; esi = 0 clear all rows
233
; edi - number text line
234
clear_line_before_draw:
235
  push eax ebx ecx edx
236
    sub ebx,0x10001 ;отнимаем отступы для выравнивания буквы по центру
237
    cmp esi,0
238
    jne @f
239
      add bx,word[recMain.height]
240
      inc edi ; ???
241
      ror ebx,16
242
      mov bx,word[wndMain.left]
243
      add bx,word[recMain.left]
244
      ror ebx,16
245
    @@:
246
 
247
    mov ax,word[wndMain.height]
248
    add ax,word[wndMain.top]
249
    cmp ax,bx
250
    jl .no_clear
251
    sub ax,bx
252
 
253
    mov cx,bx
254
    shl ecx,16
255
 
256
    mov bx,word[wndMain.width]
257
    sub bx,word[recMain.left]
258
    mov cx,word[recMain.height]
259
    mov edx,[WND_WORK_COLOR]
260
 
261
    cmp esi,0
262
    je .pusto
263
    cmp ax,cx
264
    jge @f
265
      .pusto:
266
      mov cx,ax
267
    @@:
268
 
269
    call IsSel
270
    cmp al,0
271
    je @f
272
    cmp [seln.y0],edi
273
    jg @f
274
    cmp [seln.y1],edi
275
    jl @f
276
      mov edx,[SELECT_COLOR] ;draw selected line
277
    @@:
278
 
279
    mov eax,13 ;rect
280
    int 0x40
281
 
282
    call IsSel
283
    cmp al,0
284
    je .no_clear
285
 
286
    mov al,13 ;rect
287
    mov cx,word[recMain.height]
288
    cmp [seln.y0],edi
289
    jne @f
290
      push bx
291
      mov edx,[seln.x0] ; верхняя полоса (затирает слева)
292
      cmp edx,[hScr.position]
293
      jle .in_wnd
294
	sub edx,[hScr.position]
295
	imul edx,[recMain.width]
296
	mov bx,dx
297
	jmp .no_wnd
298
      .in_wnd:
299
	mov bx,0
300
      .no_wnd:
301
      mov edx,[WND_WORK_COLOR]
302
      int 0x40
303
      pop bx
304
    @@:
305
    cmp [seln.y1],edi
306
    jne @f
307
      mov edx,[seln.x1] ; нижняя полоса (затирает справа)
308
      cmp edx,[hScr.position]
309
      jle .in_wnd2
310
	sub edx,[hScr.position]
311
	imul edx,[recMain.width]
312
	sub bx,dx
313
	shl edx,16
314
	add ebx,edx
315
      .in_wnd2:
316
 
317
      mov edx,[WND_WORK_COLOR]
318
      int 0x40
319
    @@:
320
 
321
  .no_clear:
322
  pop edx ecx ebx eax
323
  ret
324
 
325
;include 't_debug.inc'
326
draw_main_win:
327
  push eax ebx ecx edx edi esi
328
;---debug---
329
;mov ecx,0
330
;@@:
331
;call DebugSymb
332
;inc ecx
333
;cmp ecx,10
334
;jge @f
335
;jmp @b
336
;@@:
337
;ret
338
;---debug---
339
 
340
  mov eax,4 ;draw text
341
  mov esi,1
342
  mov ecx,[tex_colors]
343
  push dword[ecx]
344
  pop ecx
345
 
346
  mov ebx,[wndMain.left]
347
  add ebx,[recMain.left]
348
  inc ebx
349
  shl ebx,16
350
  add ebx,[wndMain.top]
351
  add ebx,[recMain.top]
352
  inc ebx
353
 
354
  call SelNormalize ;need before draw select
355
  mov edi,[wScr.position]
356
 
357
  call clear_line_before_draw
358
  call GetFirstVisiblePos
359
  cmp edx,0
360
  je .no_draw_text
361
  @@:
362
    call IteratNext
363
    cmp edx,[tex_1]
364
    jle .no_draw_text
365
 
366
;--- debug
367
;cmp dword[edx+6],maxChars
368
;jge .no_draw_text
369
;--- debug
370
 
371
    ; *** цветовая разметка
372
    cmp byte[mode_colored],0
373
    je .no_col_change
374
    cmp byte[edx+1],0
375
    je .no_col_change
376
      call GetSymbColor
377
    .no_col_change:
378
 
379
    cmp byte [edx],13
380
    jne .no_13
381
      cmp [invis],1
382
      jne .no_invis
383
	push edx
384
	mov edx,symbol_new_line
385
	int 0x40
386
	pop edx
387
      .no_invis:
388
      add bx,word [recMain.height]
389
      ;optimized output \/
390
      mov ax,word [wndMain.height]
391
      add ax,word [wndMain.top]
392
      cmp bx,ax
393
      jg .no_draw_text
394
      mov ax,4
395
      ;optimized output /\
396
      ror ebx,16
397
      mov bx,word [wndMain.left]
398
      add bx,word [recMain.left]
399
      inc ebx
400
      ror ebx,16
401
      inc edi ;increment line number
402
      call clear_line_before_draw
403
      call OptDrawLineLeft
404
      jmp @b
405
    .no_13:
406
 
407
    int 0x40
408
    ror ebx,16
409
    add bx,word [recMain.width]
410
    mov si,word [wndMain.left]
411
    add si,word [wndMain.width]
412
    cmp bx,si
413
    jl .no_opt
414
      call OptDrawLineRight
415
    .no_opt:
416
    mov si,1
417
    ror ebx,16
418
    jmp @b
419
  .no_draw_text:
420
  xor esi,esi
421
  call clear_line_before_draw
422
 
423
 
424
  mov eax,13
425
  ;top panel with caption
426
  mov ebx,[wndMain.left]
427
;  add ebx,[recMain.left]
428
  shl ebx,16
429
  add ebx,[wndMain.width]
430
;  sub ebx,[recMain.left]
431
  mov edx,[WND_WORK_COLOR]
432
  mov ecx,[wndMain.top] ;draw caption
433
  shl ecx,16
434
  add ecx,[recMain.top]
435
  mov edx,[WND_CAPT_COLOR]
436
  int 0x40
437
  ;left panel with numbers
438
;  mov ebx,[wndMain.left]
439
;  shl ebx,16
440
;  add ebx,[recMain.left]
441
  ;mov cx,word[wndMain.height]
442
;  mov cx,word[recMain.top]
443
;  int 0x40
444
 
445
  call draw_line_numbers
446
  call draw_main_cursor
447
 
448
;---------------------------------------------
449
; set all_redraw flag for draw all ScrollBar
450
; In some cases it is necessity to draw only the area
451
; of moving of a "runner", for acceleration of output -
452
; in this case the flag needs to be reset to 0 (zero).
453
	xor	eax,eax
454
	inc	eax
455
	mov	[wScr.all_redraw],eax
456
	mov	[hScr.all_redraw],eax
457
 
458
; draw for Vertical ScrollBar
459
	push	 dword wScr
460
	call	 [scrollbar_ver_draw]
461
	push	 dword hScr
462
	call	 [scrollbar_hor_draw]
463
; reset all_redraw flag
464
	xor	eax,eax
465
	mov	[wScr.all_redraw],eax
466
	mov	[hScr.all_redraw],eax
467
;---------------------------------------------
468
 
469
  mov eax,13
470
  ;left-bottom square
471
  mov bx,word[wndMain.left]
472
  shl ebx,16
473
  mov bx,word[recMain.left]
474
  mov ecx,[wndMain.top]
475
  add ecx,[wndMain.height]
476
  shl ecx,16
477
  mov cx,word[hScr.size_y]
478
  inc cx
479
  mov edx,[sc.work]
480
  int 0x40
481
 
482
  ;right-bottom square
483
  mov ebx,[wndMain.left]
484
  add ebx,[wndMain.width]
485
  shl ebx,16
486
  mov bx,word[wScr.size_x]
487
  inc bx
488
  int 0x40
489
 
490
  pop esi edi edx ecx ebx eax
491
  call draw_panel_find
492
  call draw_panel_syntax
493
  ret
494
 
495
;txtBUp db 24
496
;txtBDn db 25
497
;txtBRi db 26
498
;txtBLe db 27
499
draw_panel_find:
500
  cmp byte[panel_id],TE_PANEL_FIND ;if not panel
501
  jne @f
502
  push eax ebx ecx edx
503
 
504
  mov eax,13 ;рисование прямоугольника
505
  mov ebx,TE_PANEL_WIDTH
506
  mov cx,word[wndMain.top]
507
  shl ecx,16
508
  mov cx,20
509
  mov edx,[sc.work]
510
  int 0x40
511
 
512
  mov eax,4 ;рисование текста
513
  mov ebx,30*65536+5
514
  add bx,word[wndMain.top]
515
  mov ecx,[sc.work_text]
516
  or ecx,0x80000000
517
  mov edx,txtFindCapt
518
  int 0x40
519
 
520
  push dword edit2
521
  call [edit_box_draw]
522
 
523
  mov eax,13 ;рисование прямоугольника
524
  mov ebx,TE_PANEL_WIDTH
525
  mov cx,word[wndMain.top]
526
  add cx,20+15 ; 15 - height text box
527
  shl ecx,16
528
  mov cx,word[wndMain.height]
529
  add cx,word[hScr.size_y]
530
  sub cx,20+15-1 ; 15 - height text box
531
  mov edx,[sc.work]
532
  int 0x40
533
 
534
  mov eax,8 ;кнопка
535
  mov ebx,5*65536+85
536
  mov cx,word[wndMain.top]
537
  add cx,20+15+5
538
  shl ecx,16
539
  mov cx,20
540
  mov edx,201 ;button id
541
  mov esi,[sc.work_button]
542
  int 0x40
543
 
544
  mov eax,4 ;рисование текста
545
  mov ebx,15*65536+(20+15+10)
546
  add bx,word[wndMain.top]
547
  mov ecx,[sc.work_text]
548
  or ecx,0x80000000
549
  mov edx,txtFindNext
550
  int 0x40
551
 
552
  pop edx ecx ebx eax
553
  ret
554
  @@:
555
  push eax edx
556
    mov eax,8
557
    mov edx,201
558
    or edx,0x80000000
559
    int 0x40
560
  pop edx eax
561
  ret
562
 
563
draw_panel_syntax:
564
  cmp byte[panel_id],TE_PANEL_SYNTAX ;if not panel
565
  jne @f
566
  push eax ebx ecx edx
567
 
568
  mov eax,13 ;рисование прямоугольника
569
  mov ebx,TE_PANEL_WIDTH
570
  mov cx,word[wndMain.top]
571
  shl ecx,16
572
  mov cx,20
573
  mov edx,[sc.work]
574
  int 0x40
575
 
576
  push dword tree1
577
  call dword[tl_draw]
578
 
579
  mov	[ws_dir_lbox.all_redraw],1
580
  push dword ws_dir_lbox
581
  call dword[scrollbar_ver_draw]
582
 
583
  ror ecx,16
584
  add ecx,dword[tree1.box_height]
585
  add ecx,20
586
  ror ecx,16
587
  mov cx,word[wndMain.height]
588
  add cx,word[hScr.size_y]
589
  sub cx,20
590
  sub ecx,dword[tree1.box_height]
591
  inc cx
592
  int 0x40
593
 
594
  mov eax,8 ;кнопка
595
  mov ebx,5*65536+65
596
  mov cx,word[wndMain.top]
597
  add cx,25
598
  add ecx,dword[tree1.box_height]
599
  shl ecx,16
600
  mov cx,20
601
  mov edx,200 ;button id
602
  mov esi,[sc.work_button]
603
  int 0x40
604
 
605
  mov eax,4 ;рисование текста
606
  mov ebx,30*65536+5
607
  add bx,word[wndMain.top]
608
  mov ecx,[sc.work_text]
609
  or ecx,0x80000000
610
  mov edx,txtFormatCapt
611
  int 0x40
612
 
613
  mov ebx,10*65536+30
614
  add ebx,dword[tree1.box_height]
615
  add bx,word[wndMain.top]
616
  mov edx,txtFormatApply
617
  int 0x40
618
 
619
  pop edx ecx ebx eax
620
  ret
621
  @@:
622
  push eax edx
623
    mov eax,8
624
    mov edx,200
625
    or edx,0x80000000
626
    int 0x40
627
  pop edx eax
628
  ret
629
 
630
draw_cur_line:
631
  push eax ebx ecx edx esi edi
632
 
633
    mov edi,[cur_y]
634
 
635
    mov ebx,[wndMain.left]
636
    add ebx,[recMain.left]
637
    inc ebx
638
    shl ebx,16
639
    add ebx,edi
640
    imul bx,word[recMain.height]
641
    add ebx,[wndMain.top]
642
    add ebx,[recMain.top]
643
    inc ebx
644
 
645
    add edi,[wScr.position]
646
    mov esi,1
647
    call SelNormalize ;need before draw select
648
    call clear_line_before_draw
649
 
650
    mov esi,[hScr.position]
651
    mov ecx,edi
652
    call GetPosByParam
653
 
654
  cmp [gpOpt],2
655
  jne .no_draw_text
656
;  mov eax,4 ;draw text
657
  call GetSymbColor
658
  mov esi,1 ;draw 1 symbol
659
  @@:
660
    ;call IteratNext
661
    cmp edx,[tex_1]
662
    jle .no_draw_text
663
 
664
    ; *** цветовая разметка
665
    cmp byte[mode_colored],0
666
    je .no_col_change
667
    cmp byte[edx+1],0
668
    je .no_col_change
669
      call GetSymbColor
670
    .no_col_change:
671
 
672
    mov eax,4 ;draw text
673
    cmp byte [edx],13
674
    jne .no_13
675
      cmp [invis],1
676
      jne .no_draw_text
677
 push edx
678
 mov edx,symbol_new_line
679
 int 0x40
680
 pop edx
681
      jmp .no_draw_text
682
    .no_13:
683
 
684
    int 0x40
685
    ror ebx,16
686
    add bx,word[recMain.width]
687
;    cmp bx,word[wndMain.width]
688
    mov ax,word[wndMain.width]
689
    add ax,word[wndMain.left] ;ax = отступ по оси x
690
    cmp bx,ax
691
    jge .no_draw_text ;Opt
692
    ror ebx,16
693
    call IteratNext
694
    jmp @b
695
  .no_draw_text:
696
 
697
  pop edi esi edx ecx ebx eax
698
  call draw_main_cursor
699
  ret
700
 
701
MIN_M_WND_H equ 100
702
MIN_W_SCRL_ARE equ 3
703
MIN_H_SCRL_ARE equ 3
704
EvSize:
705
  push eax ecx edx edi
706
  m2m [wndMain.width],[procinfo.client_box.width]
707
  mov ax,word[wndMain.left]
708
  sub word[wndMain.width],ax
709
  mov eax,[wScr] ;+0 size_x
710
  sub word[wndMain.width],ax
711
 
712
  m2m [wndMain.height],[procinfo.client_box.height]
713
  cmp [wndMain.height],MIN_M_WND_H
714
  jg @f
715
    mov [wndMain.height],MIN_M_WND_H
716
  @@:
717
 
718
  mov ax,word[hScr.size_y]
719
  sub word[wndMain.height],ax
720
    mov eax,[wndMain.height] ;.height = .top+.height
721
    mov word[hScr.start_y],ax
722
  mov eax,[wndMain.top]
723
  sub word[wndMain.height],ax
724
 
725
  m2m word[wScr.start_x],word[wndMain.width]
726
  mov ax,word[wndMain.left]
727
  add [wScr.start_x],ax
728
  m2m word[wScr.size_y],word[wndMain.height]
729
 
730
  m2m word[hScr.start_x],word[recMain.left]
731
  add [hScr.start_x],ax ;ax=[wndMain.left]
732
  mov eax,[wndMain.width]
733
  sub ax,word[recMain.left]
734
  mov word[hScr.size_x],ax
735
 
736
  mov eax,[wndMain.height] ;calculate lines in page
737
  sub eax,[recMain.top]
738
  xor edx,edx
739
  mov ecx,[recMain.height]
740
  div ecx
741
  cmp eax,MIN_W_SCRL_ARE
742
  jg @f
743
    mov eax,MIN_W_SCRL_ARE
744
  @@:
745
  mov [wScr.cur_area],eax
746
 
747
  mov eax,[wndMain.width] ;calculate cols in page
748
  sub eax,[recMain.left]
749
  xor edx,edx
750
  mov ecx,[recMain.width]
751
  div ecx
752
  cmp eax,MIN_H_SCRL_ARE
753
  jg @f
754
    mov eax,MIN_H_SCRL_ARE
755
  @@:
756
  dec eax ; ???
757
  mov [hScr.cur_area],eax
758
 
759
  mov edi,dword tree1
760
  m2m tl_box_top,dword[wndMain.top]
761
  add tl_box_top,20
762
 
763
  m2m dword[edit2.top],dword[wndMain.top]
764
  add dword[edit2.top],20
765
 
766
  pop edi edx ecx eax
767
  call OnInitialUpdate
768
  ret
769
 
770
OnInitialUpdate:
771
  mov [wScr.redraw],1
772
  mov [hScr.redraw],1
773
  ret
774
 
775
;output:
776
; edx = pointer to symbol
777
; edx = 0 if text not in screen
778
GetFirstVisiblePos:
779
  push ecx
780
  mov edx,[tex]
781
  xor ecx,ecx
782
  @@:
783
    cmp ecx,[wScr.position]
784
    je @f
785
    call IteratNext
786
    cmp edx,[tex_1]
787
    jle @f
788
    cmp byte [edx],13
789
    jne @b
790
    inc ecx
791
    jmp @b
792
  @@:
793
 
794
  cmp ecx,[wScr.position]
795
  je @f
796
    xor edx,edx
797
  @@:
798
  cmp ecx,[wScr.max_area]
799
  jle @f
800
    mov [wScr.max_area],ecx
801
  @@:
802
  pop ecx
803
  call OptDrawLineLeft
804
  ret
805
 
806
 
807
 
808
;input:
809
; edx = pointer to symbol
810
;output:
811
; edx = pointer to first left symbol
812
OptDrawLineLeft:
813
  push ecx
814
  mov ecx,[hScr.position]
815
  cmp ecx,0
816
  je .ret_f
817
  push eax
818
  mov eax,edx
819
 
820
  cmp edx,[tex]
821
  jne @f
822
    call IteratNext
823
    jmp .beg_cycle
824
  @@:
825
 
826
  cmp ecx,0
827
  je @f
828
 
829
  cmp byte[edx],13
830
  jne @f
831
    call IteratNext
832
    .beg_cycle:
833
  @@:
834
    cmp edx,[tex_1]
835
    jle @f
836
    cmp byte[edx],13
837
    je @f
838
    cmp ecx,0
839
    je @f
840
    mov eax,edx
841
    call IteratNext
842
    dec ecx
843
    jmp @b
844
  @@:
845
    mov edx,eax
846
  pop eax
847
  .ret_f:
848
  pop ecx
849
  call GetSymbColor
850
  ret
851
 
852
;input:
853
; edx = pointer to symbol
854
;output:
855
; edx = pointer to 13 symbol
856
OptDrawLineRight:
857
  push eax
858
  mov eax,edx
859
  @@:
860
    cmp edx,[tex_1]
861
    jle @f
862
    cmp byte[edx],13
863
    je @f
864
    mov eax,edx
865
    call IteratNext
866
    jmp @b
867
  @@:
868
  mov edx,eax ;perv sumbol
869
  pop eax
870
  call GetSymbColor
871
  ret
872
 
873
draw_main_cursor:
874
  push eax ebx ecx edx edi esi
875
 
876
  mov eax,13 ;draw cursor
877
  mov ecx,[wndMain.top] ;calc rect -> y0,y1
878
  add ecx,[recMain.top]
879
  mov edx,[cur_y]
880
  imul edx,[recMain.height]
881
  add ecx,edx
882
 
883
  cmp [curMod],1
884
  jne @f
885
    mov edx,[recMain.height]
886
    inc edx ; 1->1, 3->2, 5->3, ...
887
    shr edx,1
888
    add ecx,edx
889
  @@:
890
  shl ecx,16
891
  add ecx,[recMain.height]
892
  cmp [curMod],1
893
  jne @f
894
    shr cx,1
895
  @@:
896
 
897
  mov ebx,[wndMain.left] ;calc rect -> x0,x1
898
  add ebx,[recMain.left]
899
  mov edx,[cur_x]
900
  imul edx,[recMain.width]
901
  add ebx,edx
902
  shl ebx,16
903
  add ebx,[recMain.width]
904
 
905
  mov edx,[CURSOR_COLOR]
906
  int 0x40
907
 
908
  call GetPos
909
  cmp [gpOpt],2
910
  jne @f
911
    mov eax,4 ;draw text
912
    mov esi,1
913
    ror ecx,16
914
    mov bx,cx
915
    add ebx,0x10001
916
    cmp [curMod],1
917
    jne .no_up_tetx
918
      mov cx,word[recMain.height]
919
      inc cx ; 1->1, 3->2, 5->3, ...
920
      shr cx,1
921
      sub bx,cx
922
    .no_up_tetx:
923
    mov ecx,[CUR_TEXT_COLOR]
924
    call ConvertInvisSymb
925
    int 0x40
926
  @@:
927
 
928
 
929
 
930
  mov eax,4
931
  mov ebx,[wndMain.left]
932
  add ebx,[recMain.left]
933
  shl ebx,16
934
  add ebx,[wndMain.top]
935
  add ebx,3
936
  mov ecx,[WND_BORD_COLOR]
937
  or  ecx,0x80000000
938
  mov edx,txtRow
939
  int 0x40
940
 
941
  add ebx,0x500000
942
  mov edx,txtCol
943
  int 0x40
944
 
945
  cmp [tim_Undo],0
946
  je @f
947
    add ebx,0x500000
948
    mov edx,txtOtm
949
    int 0x40
950
    sub ebx,0x500000
951
  @@:
952
 
953
  call draw_bufer
954
  call draw_help_f1
955
 
956
  mov eax,47 ;draw cursor coords
957
  mov esi,[WND_BORD_COLOR]
958
  or  esi,0x40000000
959
  mov edi,[WND_WORK_COLOR]
960
 
961
  mov edx,ebx
962
  ror edx,16
963
  sub edx,35
964
  ror edx,16
965
  ;add edx,3
966
  mov ebx,0x40000 ;Row=...
967
  mov ecx,[cur_y]
968
  inc ecx
969
  add ecx,[wScr.position]
970
  int 0x40
971
 
972
  ;mov ebx,0x40000 ;Col=...
973
  mov ecx,[cur_x]
974
  inc ecx
975
  add ecx,[hScr.position]
976
  add edx,0x500000
977
  int 0x40
978
 
979
  cmp [tim_Undo],0
980
  je @f
981
    mov ecx,[tim_Undo]
982
    add edx,0x500000
983
    int 0x40
984
  @@:
985
 
986
  pop esi edi edx ecx ebx eax
987
  ret
988
 
989
 
990
draw_bufer:
991
  push eax ebx ecx edx esi edi
992
  cmp byte[buf],0
993
  je @f
994
    mov ebx,[wndMain.left]
995
    add ebx,[recMain.left]
996
  add bx,250
997
    shl ebx,16
998
    add ebx,[wndMain.top]
999
    add ebx,3
1000
    mov ecx,[WND_BORD_COLOR]
1001
    or	ecx,0x40000000
1002
    mov edi,[WND_WORK_COLOR]
1003
 
1004
    mov edx,txtBuf
1005
    mov esi,buf
1006
    call strlen
1343 IgorA 1007
if lang eq ru
1338 IgorA 1008
    cmp eax,15
1009
    jle .crop_buf
1010
      mov eax,15
1011
    .crop_buf:
1343 IgorA 1012
    mov esi,7 ;7=len(txtBuf)
1013
else
1014
    cmp eax,14
1015
    jle .crop_buf
1016
      mov eax,14
1017
    .crop_buf:
1018
    mov esi,8 ;8=len(txtBuf)
1019
end if
1338 IgorA 1020
    add esi,eax
1021
 
1022
    mov eax,4
1023
    int 0x40
1024
  @@:
1025
  pop edi esi edx ecx ebx eax
1026
  ret
1027
 
1028
draw_help_f1:
1029
  push eax ebx ecx edx edi
1030
  mov eax,13 ;clear place before draw help
1031
  mov ebx,[wndMain.left]
1032
  add ebx,[recMain.left]
1033
  shl ebx,16
1034
  add ebx,[wndMain.width]
1035
  sub ebx,[recMain.left]
1036
  mov ecx,[wndMain.top]
1037
  add ecx,13
1038
  shl ecx,16
1039
  add ecx,[recMain.height]
1040
  mov edx,[WND_CAPT_COLOR]
1041
  int 0x40
1042
 
1043
  cmp [help_id],-1
1044
  je @f;.no_help
1045
    mov eax,[help_id]
1046
    ColToIndexOffset eax,edx
1047
 
1048
    ;SetCoordinates
1049
    mov ebx,[wndMain.left]
1050
    add ebx,[recMain.left]
1051
    shl ebx,16
1052
    add ebx,[wndMain.top]
1053
    add ebx,13 ;=3+10
1054
 
1055
    ;SetTextColor
1056
    xor eax,eax
1057
    mov al,byte[edx+MAX_COLOR_WORD_LEN+6]
1058
    shl ax,2
1059
    mov ecx,[tex_colors]
1060
    add ecx,eax
1061
    push dword[ecx]
1062
    pop ecx
1063
    or	ecx,0xc0000000 ;SetTextStyles
1064
    mov edi,[WND_WORK_COLOR]
1065
 
1066
    mov eax,4
1067
    int 0x40
1068
 
1069
    ;*** draw help string ***
1070
    mov ecx,[WND_BORD_COLOR]
1071
    or ecx,0x80000000
1072
    mov edi,dword[edx+MAX_COLOR_WORD_LEN]
1073
    cmp edi,0
1074
    je @f
1075
      add edi,dword[tex_help_f1]
1076
      mov edx,edi
1077
      add ebx,0x500000
1078
      int 0x40
1079
    @@:
1080
  ;.no_help:
1081
  pop edi edx ecx ebx eax
1082
  ret
1083
 
1084
draw_line_numbers:
1085
  push eax ebx ecx edx esi ;edi
1086
  ;line numbers
1087
  mov eax,47
1088
  mov esi,[WND_BORD_COLOR]
1089
  ;or esi,0x40000000
1090
  ;mov edi,[WND_WORK_COLOR]
1091
  mov ebx,0x40000 ;format
1092
 
1093
  mov ecx,[wScr.position]
1094
  inc ecx
1095
  mov dx,3
1096
  add dx,word[wndMain.left]
1097
  shl edx,16
1098
  mov dx,word[wndMain.top]
1099
  add dx,word[recMain.top]
1100
  @@:
1101
 
1102
push eax ebx ecx edx
1103
  mov eax,13
1104
  ;left panel with numbers
1105
  mov ebx,[wndMain.left]
1106
  shl ebx,16
1107
  add ebx,[recMain.left]
1108
  mov cx,dx
1109
;  mov ecx,[wndMain.top] ;draw caption
1110
;  add ecx,[recMain.top]
1111
  shl ecx,16
1112
  mov cx,word [recMain.height]
1113
  mov edx,[WND_CAPT_COLOR]
1114
  int 0x40
1115
pop edx ecx ebx eax
1116
 
1117
    int 0x40
1118
    inc ecx
1119
    add dx,word[recMain.height]
1120
    sub dx,word[wndMain.top]
1121
    cmp dx,word[wndMain.height]
1122
    jge @f
1123
    add dx,word[wndMain.top]
1124
    jmp @b
1125
  @@:
1126
 
1127
  pop esi edx ecx ebx eax
1128
  ret
1129
 
1130
 
1131
draw_cursor_sumb: ;this function need to optimize output
1132
  push eax ecx edx
1133
  mov eax,13 ;rect
1134
  mov ebx,[wndMain.left]
1135
  add ebx,[recMain.left]
1136
  mov edx,[cur_x]
1137
  imul edx,[recMain.width]
1138
  add ebx,edx
1139
  shl ebx,16
1140
  add ebx,[recMain.width]
1141
 
1142
  mov ecx,[wndMain.top] ;calc rect -> y0,y1
1143
  add ecx,[recMain.top]
1144
  mov edx,[cur_y]
1145
  imul edx,[recMain.height]
1146
  add ecx,edx
1147
  shl ecx,16
1148
  add ecx,[recMain.height]
1149
 
1150
  mov edx,[WND_WORK_COLOR]
1151
  push ecx
1152
    call SelNormalize
1153
 
1154
    mov ecx,[wScr.position]
1155
    sub [seln.y0],ecx
1156
    sub [seln.y1],ecx
1157
 
1158
    mov ecx,[cur_y]
1159
    cmp ecx,[seln.y0]
1160
    jl .no_cur_sel
1161
    cmp ecx,[seln.y1]
1162
    jg .no_cur_sel
1163
    mov edx,[SELECT_COLOR]
1164
 
1165
    cmp ecx,[seln.y0]
1166
    jne @f
1167
      mov ecx,[cur_x]
1168
      add ecx,[hScr.position]
1169
      cmp ecx,[seln.x0]
1170
      jge @f
1171
	mov edx,[WND_WORK_COLOR]
1172
    @@:
1173
 
1174
    mov ecx,[cur_y]
1175
    cmp ecx,[seln.y1]
1176
    jne .no_cur_sel
1177
      mov ecx,[cur_x]
1178
      add ecx,[hScr.position]
1179
      cmp ecx,[seln.x1]
1180
      jl .no_cur_sel
1181
      mov edx,[WND_WORK_COLOR]
1182
 
1183
    .no_cur_sel:
1184
  pop ecx
1185
  int 0x40
1186
 
1187
  call GetPos
1188
  cmp [gpOpt],2
1189
  jne @f
1190
    push esi
1191
    mov eax,4 ;draw text
1192
    mov esi,1
1193
    ror ecx,16
1194
    mov bx,cx
1195
    add ebx,0x10001
1196
    ;mov ecx,[WND_TEXT_COLOR]
1197
    call GetSymbColor
1198
    call ConvertInvisSymb
1199
    int 0x40
1200
    pop esi
1201
  @@:
1202
 
1203
  pop edx ecx eax
1204
  ret
1205
 
1206
 
1207
 
1208
;input:
1209
; edx = pointer to text
1210
;output:
1211
; ecx = color
1212
; if mode_colored=0 then ecx=WND_TEXT_COLOR
1213
GetSymbColor:
1214
  mov ecx,[WND_TEXT_COLOR]
1215
 
1216
  push eax edx
1217
  cmp byte[mode_colored],0
1218
  je .exit
1219
    jmp .on_first
1220
    @@:
1221
      call IteratPerv
1222
      cmp edx,[tex_1]
1223
      jle .exit
1224
    .on_first:
1225
      xor eax,eax
1226
      mov al,byte[edx+1]
1227
      cmp al,0
1228
    je @b
1229
 
1230
    ;cmp al,0xff
1231
    ;je .exit
1232
    cmp eax,[ColColor]
1233
    jge .exit
1234
 
1235
    shl ax,2 ;*4
1236
    mov ecx,[tex_colors]
1237
    add ecx,eax
1238
    push dword[ecx]
1239
    pop ecx
1240
  .exit:
1241
  pop edx eax
1242
  ret
1243
 
1244
;input:
1245
; edx = pointer to text
1246
ConvertInvisSymb:
1247
  cmp [invis],1
1248
  jne @f
1249
  cmp byte [edx],13
1250
  jne @f
1251
    mov edx,symbol_new_line
1252
  @@:
1253
  ret
1254
 
1255
;input:
1256
;  ecx = 0x4000____
1257
;   cx = icon index
1258
;  edx = x*2^16+y
1259
draw_but_icon:
1260
  push eax ebx
1261
 
1262
  mov eax,8 ;кнопка
1263
  push ecx edx esi
1264
  mov ebx,edx
1265
  mov edx,ecx
1266
  add edx,3
1267
  mov cx,bx
1268
  shl ecx,16
1269
  mov cx,19 ;=20-1
1270
  mov bx,19 ;=20-1
1271
  mov esi,[sc.work_button]
1272
  int 0x40
1273
  pop esi edx ecx
1274
 
1275
  mov ebx,ecx
1276
  ror ebx,16
1277
  cmp bx,0x4000
1278
  jne @f
1279
 
1280
  mov eax,7 ;bmp
1281
  mov ebx,[bmp_icon]
1282
  push ecx
1283
  and ecx,0xffff
1284
  imul ecx,1200
1285
  add ebx,ecx
1286
  mov ecx,20
1287
  shl ecx,16
1288
  add ecx,20
1289
  int 0x40
1290
  pop ecx
1291
 
1292
  @@:
1293
  pop ebx eax
1294
  ret
1295