Subversion Repositories Kolibri OS

Rev

Rev 1343 | Go to most recent revision | Details | 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
txtRow db '‘ва®Є ',0
874
txtCol db '‡­ Є',0
875
txtOtm db 'Ћв¬Ґ­л',0
876
 
877
draw_main_cursor:
878
  push eax ebx ecx edx edi esi
879
 
880
  mov eax,13 ;draw cursor
881
  mov ecx,[wndMain.top] ;calc rect -> y0,y1
882
  add ecx,[recMain.top]
883
  mov edx,[cur_y]
884
  imul edx,[recMain.height]
885
  add ecx,edx
886
 
887
  cmp [curMod],1
888
  jne @f
889
    mov edx,[recMain.height]
890
    inc edx ; 1->1, 3->2, 5->3, ...
891
    shr edx,1
892
    add ecx,edx
893
  @@:
894
  shl ecx,16
895
  add ecx,[recMain.height]
896
  cmp [curMod],1
897
  jne @f
898
    shr cx,1
899
  @@:
900
 
901
  mov ebx,[wndMain.left] ;calc rect -> x0,x1
902
  add ebx,[recMain.left]
903
  mov edx,[cur_x]
904
  imul edx,[recMain.width]
905
  add ebx,edx
906
  shl ebx,16
907
  add ebx,[recMain.width]
908
 
909
  mov edx,[CURSOR_COLOR]
910
  int 0x40
911
 
912
  call GetPos
913
  cmp [gpOpt],2
914
  jne @f
915
    mov eax,4 ;draw text
916
    mov esi,1
917
    ror ecx,16
918
    mov bx,cx
919
    add ebx,0x10001
920
    cmp [curMod],1
921
    jne .no_up_tetx
922
      mov cx,word[recMain.height]
923
      inc cx ; 1->1, 3->2, 5->3, ...
924
      shr cx,1
925
      sub bx,cx
926
    .no_up_tetx:
927
    mov ecx,[CUR_TEXT_COLOR]
928
    call ConvertInvisSymb
929
    int 0x40
930
  @@:
931
 
932
 
933
 
934
  mov eax,4
935
  mov ebx,[wndMain.left]
936
  add ebx,[recMain.left]
937
  shl ebx,16
938
  add ebx,[wndMain.top]
939
  add ebx,3
940
  mov ecx,[WND_BORD_COLOR]
941
  or  ecx,0x80000000
942
  mov edx,txtRow
943
  int 0x40
944
 
945
  add ebx,0x500000
946
  mov edx,txtCol
947
  int 0x40
948
 
949
  cmp [tim_Undo],0
950
  je @f
951
    add ebx,0x500000
952
    mov edx,txtOtm
953
    int 0x40
954
    sub ebx,0x500000
955
  @@:
956
 
957
  call draw_bufer
958
  call draw_help_f1
959
 
960
  mov eax,47 ;draw cursor coords
961
  mov esi,[WND_BORD_COLOR]
962
  or  esi,0x40000000
963
  mov edi,[WND_WORK_COLOR]
964
 
965
  mov edx,ebx
966
  ror edx,16
967
  sub edx,35
968
  ror edx,16
969
  ;add edx,3
970
  mov ebx,0x40000 ;Row=...
971
  mov ecx,[cur_y]
972
  inc ecx
973
  add ecx,[wScr.position]
974
  int 0x40
975
 
976
  ;mov ebx,0x40000 ;Col=...
977
  mov ecx,[cur_x]
978
  inc ecx
979
  add ecx,[hScr.position]
980
  add edx,0x500000
981
  int 0x40
982
 
983
  cmp [tim_Undo],0
984
  je @f
985
    mov ecx,[tim_Undo]
986
    add edx,0x500000
987
    int 0x40
988
  @@:
989
 
990
  pop esi edi edx ecx ebx eax
991
  ret
992
 
993
 
994
draw_bufer:
995
  push eax ebx ecx edx esi edi
996
  cmp byte[buf],0
997
  je @f
998
    mov ebx,[wndMain.left]
999
    add ebx,[recMain.left]
1000
  add bx,250
1001
    shl ebx,16
1002
    add ebx,[wndMain.top]
1003
    add ebx,3
1004
    mov ecx,[WND_BORD_COLOR]
1005
    or	ecx,0x40000000
1006
    mov edi,[WND_WORK_COLOR]
1007
 
1008
    mov edx,txtBuf
1009
    mov esi,buf
1010
    call strlen
1011
    cmp eax,15
1012
    jle .crop_buf
1013
      mov eax,15
1014
    .crop_buf:
1015
    mov esi,7
1016
    add esi,eax
1017
 
1018
    mov eax,4
1019
    int 0x40
1020
  @@:
1021
  pop edi esi edx ecx ebx eax
1022
  ret
1023
 
1024
draw_help_f1:
1025
  push eax ebx ecx edx edi
1026
  mov eax,13 ;clear place before draw help
1027
  mov ebx,[wndMain.left]
1028
  add ebx,[recMain.left]
1029
  shl ebx,16
1030
  add ebx,[wndMain.width]
1031
  sub ebx,[recMain.left]
1032
  mov ecx,[wndMain.top]
1033
  add ecx,13
1034
  shl ecx,16
1035
  add ecx,[recMain.height]
1036
  mov edx,[WND_CAPT_COLOR]
1037
  int 0x40
1038
 
1039
  cmp [help_id],-1
1040
  je @f;.no_help
1041
    mov eax,[help_id]
1042
    ColToIndexOffset eax,edx
1043
 
1044
    ;SetCoordinates
1045
    mov ebx,[wndMain.left]
1046
    add ebx,[recMain.left]
1047
    shl ebx,16
1048
    add ebx,[wndMain.top]
1049
    add ebx,13 ;=3+10
1050
 
1051
    ;SetTextColor
1052
    xor eax,eax
1053
    mov al,byte[edx+MAX_COLOR_WORD_LEN+6]
1054
    shl ax,2
1055
    mov ecx,[tex_colors]
1056
    add ecx,eax
1057
    push dword[ecx]
1058
    pop ecx
1059
    or	ecx,0xc0000000 ;SetTextStyles
1060
    mov edi,[WND_WORK_COLOR]
1061
 
1062
    mov eax,4
1063
    int 0x40
1064
 
1065
    ;*** draw help string ***
1066
    mov ecx,[WND_BORD_COLOR]
1067
    or ecx,0x80000000
1068
    mov edi,dword[edx+MAX_COLOR_WORD_LEN]
1069
    cmp edi,0
1070
    je @f
1071
      add edi,dword[tex_help_f1]
1072
      mov edx,edi
1073
      add ebx,0x500000
1074
      int 0x40
1075
    @@:
1076
  ;.no_help:
1077
  pop edi edx ecx ebx eax
1078
  ret
1079
 
1080
draw_line_numbers:
1081
  push eax ebx ecx edx esi ;edi
1082
  ;line numbers
1083
  mov eax,47
1084
  mov esi,[WND_BORD_COLOR]
1085
  ;or esi,0x40000000
1086
  ;mov edi,[WND_WORK_COLOR]
1087
  mov ebx,0x40000 ;format
1088
 
1089
  mov ecx,[wScr.position]
1090
  inc ecx
1091
  mov dx,3
1092
  add dx,word[wndMain.left]
1093
  shl edx,16
1094
  mov dx,word[wndMain.top]
1095
  add dx,word[recMain.top]
1096
  @@:
1097
 
1098
push eax ebx ecx edx
1099
  mov eax,13
1100
  ;left panel with numbers
1101
  mov ebx,[wndMain.left]
1102
  shl ebx,16
1103
  add ebx,[recMain.left]
1104
  mov cx,dx
1105
;  mov ecx,[wndMain.top] ;draw caption
1106
;  add ecx,[recMain.top]
1107
  shl ecx,16
1108
  mov cx,word [recMain.height]
1109
  mov edx,[WND_CAPT_COLOR]
1110
  int 0x40
1111
pop edx ecx ebx eax
1112
 
1113
    int 0x40
1114
    inc ecx
1115
    add dx,word[recMain.height]
1116
    sub dx,word[wndMain.top]
1117
    cmp dx,word[wndMain.height]
1118
    jge @f
1119
    add dx,word[wndMain.top]
1120
    jmp @b
1121
  @@:
1122
 
1123
  pop esi edx ecx ebx eax
1124
  ret
1125
 
1126
 
1127
draw_cursor_sumb: ;this function need to optimize output
1128
  push eax ecx edx
1129
  mov eax,13 ;rect
1130
  mov ebx,[wndMain.left]
1131
  add ebx,[recMain.left]
1132
  mov edx,[cur_x]
1133
  imul edx,[recMain.width]
1134
  add ebx,edx
1135
  shl ebx,16
1136
  add ebx,[recMain.width]
1137
 
1138
  mov ecx,[wndMain.top] ;calc rect -> y0,y1
1139
  add ecx,[recMain.top]
1140
  mov edx,[cur_y]
1141
  imul edx,[recMain.height]
1142
  add ecx,edx
1143
  shl ecx,16
1144
  add ecx,[recMain.height]
1145
 
1146
  mov edx,[WND_WORK_COLOR]
1147
  push ecx
1148
    call SelNormalize
1149
 
1150
    mov ecx,[wScr.position]
1151
    sub [seln.y0],ecx
1152
    sub [seln.y1],ecx
1153
 
1154
    mov ecx,[cur_y]
1155
    cmp ecx,[seln.y0]
1156
    jl .no_cur_sel
1157
    cmp ecx,[seln.y1]
1158
    jg .no_cur_sel
1159
    mov edx,[SELECT_COLOR]
1160
 
1161
    cmp ecx,[seln.y0]
1162
    jne @f
1163
      mov ecx,[cur_x]
1164
      add ecx,[hScr.position]
1165
      cmp ecx,[seln.x0]
1166
      jge @f
1167
	mov edx,[WND_WORK_COLOR]
1168
    @@:
1169
 
1170
    mov ecx,[cur_y]
1171
    cmp ecx,[seln.y1]
1172
    jne .no_cur_sel
1173
      mov ecx,[cur_x]
1174
      add ecx,[hScr.position]
1175
      cmp ecx,[seln.x1]
1176
      jl .no_cur_sel
1177
      mov edx,[WND_WORK_COLOR]
1178
 
1179
    .no_cur_sel:
1180
  pop ecx
1181
  int 0x40
1182
 
1183
  call GetPos
1184
  cmp [gpOpt],2
1185
  jne @f
1186
    push esi
1187
    mov eax,4 ;draw text
1188
    mov esi,1
1189
    ror ecx,16
1190
    mov bx,cx
1191
    add ebx,0x10001
1192
    ;mov ecx,[WND_TEXT_COLOR]
1193
    call GetSymbColor
1194
    call ConvertInvisSymb
1195
    int 0x40
1196
    pop esi
1197
  @@:
1198
 
1199
  pop edx ecx eax
1200
  ret
1201
 
1202
 
1203
 
1204
;input:
1205
; edx = pointer to text
1206
;output:
1207
; ecx = color
1208
; if mode_colored=0 then ecx=WND_TEXT_COLOR
1209
GetSymbColor:
1210
  mov ecx,[WND_TEXT_COLOR]
1211
 
1212
  push eax edx
1213
  cmp byte[mode_colored],0
1214
  je .exit
1215
    jmp .on_first
1216
    @@:
1217
      call IteratPerv
1218
      cmp edx,[tex_1]
1219
      jle .exit
1220
    .on_first:
1221
      xor eax,eax
1222
      mov al,byte[edx+1]
1223
      cmp al,0
1224
    je @b
1225
 
1226
    ;cmp al,0xff
1227
    ;je .exit
1228
    cmp eax,[ColColor]
1229
    jge .exit
1230
 
1231
    shl ax,2 ;*4
1232
    mov ecx,[tex_colors]
1233
    add ecx,eax
1234
    push dword[ecx]
1235
    pop ecx
1236
  .exit:
1237
  pop edx eax
1238
  ret
1239
 
1240
;input:
1241
; edx = pointer to text
1242
ConvertInvisSymb:
1243
  cmp [invis],1
1244
  jne @f
1245
  cmp byte [edx],13
1246
  jne @f
1247
    mov edx,symbol_new_line
1248
  @@:
1249
  ret
1250
 
1251
;input:
1252
;  ecx = 0x4000____
1253
;   cx = icon index
1254
;  edx = x*2^16+y
1255
draw_but_icon:
1256
  push eax ebx
1257
 
1258
  mov eax,8 ;кнопка
1259
  push ecx edx esi
1260
  mov ebx,edx
1261
  mov edx,ecx
1262
  add edx,3
1263
  mov cx,bx
1264
  shl ecx,16
1265
  mov cx,19 ;=20-1
1266
  mov bx,19 ;=20-1
1267
  mov esi,[sc.work_button]
1268
  int 0x40
1269
  pop esi edx ecx
1270
 
1271
  mov ebx,ecx
1272
  ror ebx,16
1273
  cmp bx,0x4000
1274
  jne @f
1275
 
1276
  mov eax,7 ;bmp
1277
  mov ebx,[bmp_icon]
1278
  push ecx
1279
  and ecx,0xffff
1280
  imul ecx,1200
1281
  add ebx,ecx
1282
  mov ecx,20
1283
  shl ecx,16
1284
  add ecx,20
1285
  int 0x40
1286
  pop ecx
1287
 
1288
  @@:
1289
  pop ebx eax
1290
  ret
1291