Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
1524 dunkaist 1
;   RTF READER FOR KOLIBRI >= 0.7.7.0
31 halyavin 2
;   Written in pure assembler by Ivushkin Andrey aka Willow
1515 dunkaist 3
;   Menu_bar and scroll_bar from box_lib provided by dunkaist
31 halyavin 4
;---------------------------------------------------------------------
5
M64 equ 64*1024
6
N_A equ 0x412f4e
7
RTFSIZE equ M64
8
RTFSTACKSIZE equ M64
9
BGIFONTSIZE equ 120*1024
10
ESPSIZE equ M64
1515 dunkaist 11
LMARGIN equ 15
31 halyavin 12
CHARW equ 6
13
CHARH equ 11
14
WINW  equ 600
15
WINH  equ 450
2813 leency 16
WIN_COLOR equ 0x73f0f0f0
31 halyavin 17
DEFCOLOR equ 0x303030
18
;RENDER equ PIX
19
;RENDER equ BGI
20
RENDER equ FREE
21
 
529 spraid 22
BGIFONT_PATH equ '/sys/fonts/'
31 halyavin 23
FONT_NAME equ 'LITT'
1515 dunkaist 24
TOP = 45
31 halyavin 25
MODE equ RTF
26
INVALHEX equ 0
27
RTF_COLORLESS equ 1
28
RTF_ALIGNLESS equ 2
29
RTF_NO1STLINE equ 4
30
RTF_OPENING   equ 8
31
RTF_HELP      equ 16
32
RTF_VALID     equ 32
33
RTF_BLIND     equ 64
34
RTF_TOEOF     equ 128
35
RTF_BOTTOM    equ 256
36
STEPBYSTEP equ 10
37
DEBUG_BLOCK equ 10
38
SHOWALIGN equ 10
39
GUTTER equ 10
40
BENCH  equ 0;1
41
syms equ 12
42
 
1515 dunkaist 43
;-------------------------------
44
 
2813 leency 45
SCROLL_WIDTH_SIZE       equ     15
1515 dunkaist 46
AR_OFFSET               equ     10
47
 
48
;-------------------------------
49
 
134 diamond 50
  use32              ; включить 32-битный режим ассемблера
51
  org    0x0         ; адресация с нуля
31 halyavin 52
 
134 diamond 53
  db     'MENUET01'  ; 8-байтный идентификатор MenuetOS
54
  dd     0x01        ; версия заголовка (всегда 1)
55
  dd     START       ; адрес первой команды
56
  dd     I_END0      ; размер программы
57
  dd     esp_end     ; количество памяти
58
  dd     sys_mem     ; адрес вершины стэка
59
  dd     fname_buf   ; адрес буфера для параметров (не используется)
1512 mario79 60
  dd     cur_dir_path         ; зарезервировано
31 halyavin 61
 
1702 Lrz 62
include '../../../config.inc'		;for nightbuild
1515 dunkaist 63
include '../../../macros.inc' ; макросы облегчают жизнь ассемблерщиков!
64
include '../../../develop/libraries/box_lib/trunk/box_lib.mac'
65
include '../../../develop/libraries/box_lib/load_lib.mac'
1418 mario79 66
 
67
;include 'MACROS.INC'
68
;include 'load_lib.mac'
69
 
1512 mario79 70
@use_library
71
 
3013 dunkaist 72
;include '../../../debug.inc'
1418 mario79 73
 
31 halyavin 74
if ~ RENDER eq PIX
75
  TOP=TOP+4
76
  include 'bgifont.inc'
77
end if
78
include 'rtf_lite.inc'
1515 dunkaist 79
;include 'ascl.inc'
31 halyavin 80
;---------------------------------------------------------------------
81
;---  НАЧАЛО ПРОГРАММЫ  ----------------------------------------------
82
;---------------------------------------------------------------------
83
help_file:
1515 dunkaist 84
    file  'reader.rtf'
31 halyavin 85
help_end:
86
 
87
START:
1418 mario79 88
        mcall 68, 11
1515 dunkaist 89
        mcall 40, 0x27
1418 mario79 90
 
1512 mario79 91
load_libraries l_libs_start,end_l_libs
92
 
1515 dunkaist 93
;OpenDialog     initialisation
94
        push    dword OpenDialog_data
95
        call    [OpenDialog_Init]
1512 mario79 96
 
31 halyavin 97
    mov  [pitch],2
98
  if ~ RENDER eq PIX
99
    mov  edx,FONT_NAME
100
    mov  edi,save_limit
101
    BGIfont_Prepare
102
  end if
103
 start2:
104
    cmp  byte[fname_buf],0
134 diamond 105
    je   load_file;top_red
31 halyavin 106
    jmp  noactivate
107
 prep_load:
1524 dunkaist 108
    mov  [is_scroll_bar_needed],    0
31 halyavin 109
;    mcall 18,3,dword[prcinfo+30]
110
 noactivate:
111
;    and  ebp,not RTF_OPENING
112
;    and  ebp,not RTF_HELP
113
 
114
;    and  [mode],not RTF_OPENING
115
    and  [mode],not (RTF_HELP+RTF_OPENING)
116
    mov  ecx,16
117
    mov  edi,fileinfo.name
118
    mov  esi,fname_buf
119
    rep  movsd
120
 load_file:
139 diamond 121
        mov     eax, 70
122
        and     [fileattr+32], 0
123
        mov     ebx, attrinfo
485 heavyiron 124
        mcall
139 diamond 125
        mov     ebx, [fileattr+32]
126
        test    eax, eax
127
        jz      .sizok
128
        mov     dword [fileinfo.name], N_A
129
.sizok:
31 halyavin 130
    and  [wSave],0
1515 dunkaist 131
;    mov  [HClick],-100
31 halyavin 132
    mov  eax,ebx
133
    and  eax,RTFSIZE-1
134
    add  eax,I_END
135
    mov  [tail],eax
136
    shr  ebx,16
137
;    dpd ebx
138
    mov  [max_block],ebx
139
    xor  eax,eax
140
    mov  ecx,256
141
    mov  edi,fileinfo.name
142
    repne scasb
143
    sub  edi,fileinfo.name+1
144
    mov  [fname_size],edi
145
top_red:
146
    mov  [top],TOP
1515 dunkaist 147
    mov  [scroll_bar_data_vertical.position],0
134 diamond 148
red:                    ; перерисовать окно
149
    call draw_window    ; вызываем процедуру отрисовки окна
31 halyavin 150
 
151
;---------------------------------------------------------------------
152
;---  ЦИКЛ ОБРАБОТКИ СОБЫТИЙ  ----------------------------------------
153
;---------------------------------------------------------------------
154
 
155
still:
134 diamond 156
    mcall 10            ; функция 10 - ждать события
31 halyavin 157
 
134 diamond 158
    cmp  eax,1          ; перерисовать окно ?
159
    je   red            ; если да - на метку red
160
    cmp  eax,3          ; нажата кнопка ?
161
    je   button         ; если да - на button
1515 dunkaist 162
    cmp  eax,6
163
    je   mouse
31 halyavin 164
 
165
;---------------------------------------------------------------------
166
 
167
 
2194 leency 168
key:                  ; нажата клавиша на клавиатуре
169
    mcall 2           ; функция 2 - считать код символа (в ah)
170
	;Leency[
171
	cmp eax,1
172
	jne .getkeyi
173
	mov ah,dh
174
	jmp .next
175
 
176
.getkeyi:
177
	mov dh,ah
178
	jmp key
179
 
180
.next: 	;]Leency
134 diamond 181
    cmp  ah,104         ; HELP
31 halyavin 182
    jne  .nohelp
183
  .help:
1524 dunkaist 184
    mov  [is_scroll_bar_needed],    0
31 halyavin 185
    xor  [mode],RTF_HELP
186
    test [mode],RTF_HELP
134 diamond 187
    jz   load_file
1515 dunkaist 188
    mov  dword[HDoc],200                        ; it makes the help page not scroll
31 halyavin 189
    mov  ecx,help_end-help_file
190
    mov  [block_end],ecx
191
    add  [block_end],I_END
192
    mov  [tail],ecx
193
    add  [tail],I_END
194
    mov  esi,help_file
195
    mov  edi,I_END
196
    rep  movsb
197
;    or   [mode],RTF_HELP
198
    xor  eax,eax
199
    mov  [max_block],eax
200
    jmp  top_red
201
  .nohelp:
202
;    test [mode],RTF_HELP
203
;    jz   .nohelp2
204
;    and  [mode],not RTF_HELP
205
;    cmp  dword[fileinfo.name],N_A
206
;    je   still
207
;    jmp  prep_load
208
  .nohelp2:
134 diamond 209
    cmp  ah,114         ; R - redraw
210
    je   red
211
    cmp  ah,99          ; C - color
31 halyavin 212
    jne  .nocolor
213
  .color:
214
    xor  [mode],RTF_COLORLESS
215
    jmp  red
216
  .nocolor:
134 diamond 217
    cmp  ah,97          ; A - alignment
31 halyavin 218
    jne  .noalign
219
  .alignment:
220
    xor  [mode],RTF_ALIGNLESS
221
    jmp  red
222
  .noalign:
134 diamond 223
    cmp  ah,44          ; < - pitch dec
31 halyavin 224
    jne  .nopd
225
  .decp:
226
    dec  [pitch]
227
    jmp  red
228
  .nopd:
134 diamond 229
    cmp  ah,46          ; < - pitch inc
31 halyavin 230
    jne  .nopi
231
  .incp:
232
    inc  [pitch]
233
    jmp  red
234
  .nopi:
134 diamond 235
    cmp  ah,180         ; Home
236
    je   top_red
1515 dunkaist 237
 
1524 dunkaist 238
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 239
     je  still
240
 
31 halyavin 241
    mov  ebx,dword[prcinfo+46]
242
    sub  ebx,TOP+15
243
    cmp  ah,183 ;PgDn
244
    jne  .nopgdn
1515 dunkaist 245
;    sub  [top],bx
246
 
1524 dunkaist 247
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 248
     je  still
249
 
250
    mov  eax, [scroll_bar_data_vertical.position]
251
    add  eax, AR_OFFSET*7
252
    mov  ebx, [scroll_bar_data_vertical.max_area]
253
    sub  ebx, [scroll_bar_data_vertical.cur_area]
254
    cmp  eax, ebx
255
    mov  dword[scroll_bar_data_vertical.position], eax
256
    jl  @f
257
    mov  dword[scroll_bar_data_vertical.position], ebx
258
  @@:
259
    call Set_position
31 halyavin 260
    jmp  red
261
  .nopgdn:
262
    cmp  ah,177 ;arrDn
263
    jne  .noardn
1515 dunkaist 264
;    sub  [top],CHARH
265
 
1524 dunkaist 266
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 267
     je  still
268
 
269
    mov  eax, [scroll_bar_data_vertical.position]
270
    add  eax, AR_OFFSET
271
    mov  ebx, [scroll_bar_data_vertical.max_area]
272
    sub  ebx, [scroll_bar_data_vertical.cur_area]
273
    cmp  eax, ebx
274
    mov  dword[scroll_bar_data_vertical.position], eax
275
    jl  @f
276
    mov  dword[scroll_bar_data_vertical.position], ebx
277
  @@:
278
    call Set_position
279
 
31 halyavin 280
    jmp  red
281
  .noardn:
282
    mov  cx,[top]
283
    cmp  ah,184 ;PgUp
284
    jne  .nopgup
1515 dunkaist 285
;    add  [top],bx
286
;    cmp  [top],TOP
287
;    jl   red
288
;    mov  [top],TOP
289
;    cmp  cx,[top]
290
;    je   still
291
 
1524 dunkaist 292
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 293
     je  still
294
 
295
    cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
296
    sub  dword[scroll_bar_data_vertical.position], AR_OFFSET*7
297
    jg  @f
298
    mov  dword[scroll_bar_data_vertical.position], 0
299
  @@:
300
    call Set_position
31 halyavin 301
    jmp  red
302
  .nopgup:
303
    cmp  ah,178 ;arrUp
304
    jne  .noarup
1515 dunkaist 305
;    add  [top],CHARH
306
 
1524 dunkaist 307
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 308
     je  still
309
 
310
    cmp  dword[scroll_bar_data_vertical.position], AR_OFFSET
311
    sub  dword[scroll_bar_data_vertical.position], AR_OFFSET
312
    jg  @f
313
    mov  dword[scroll_bar_data_vertical.position], 0
314
  @@:
315
    call Set_position
316
 
317
;    cmp  [top],TOP
318
;    jl   red
319
;    mov  [top],TOP
320
;    cmp  cx,[top]
321
;    je   still
31 halyavin 322
    jmp  red
323
  .noarup:
324
  if  RENDER eq FREE
325
    cmp  ah,56 ;zoom+
326
    jne  .noplus
327
  .zplus:
328
    fld  [FreeFontscale]
329
    fmul [Zoomscale]
330
  .zoom:
331
    fstp [FreeFontscale]
332
    jmp  red
333
  .noplus:
334
    cmp  ah,54 ;zoom-
335
    jne  .nominus
336
  .zminus:
337
    fld  [FreeFontscale]
338
    fdiv [Zoomscale]
339
    jmp  .zoom
340
  .nominus:
341
  end if
1515 dunkaist 342
    cmp  ah,0xB5        ; end
343
    jne  .pre_file_open
344
  .end:
345
 
1524 dunkaist 346
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 347
     je  still
348
 
1524 dunkaist 349
    mov  eax, [scroll_bar_data_vertical.max_area]
350
    sub  eax, [scroll_bar_data_vertical.cur_area]
351
    mov  dword[scroll_bar_data_vertical.position], eax
1515 dunkaist 352
    call Set_position
353
    jmp  red
354
  .pre_file_open:
134 diamond 355
    cmp  ah,108         ; L - load
1512 mario79 356
    jne  still
31 halyavin 357
  .file_open:
1418 mario79 358
;---------------------------------------------------------------------
359
;OpenDialog_start:
1515 dunkaist 360
;       copy_path       open_dialog_name,path,library_path,0
361
 
362
        push    dword OpenDialog_data
363
        call    [OpenDialog_Start]
1418 mario79 364
 
1515 dunkaist 365
;       cmp     [OpenDialog_data.status],2 ; OpenDialog does not start
366
;       je      .sysxtree  ;    some kind of alternative, instead OpenDialog
367
        cmp     [OpenDialog_data.status],1
368
        je      prep_load
369
        jmp     still
1418 mario79 370
;---------------------------------------------------------------------
1512 mario79 371
;.sysxtree:
372
;    or   [mode],RTF_OPENING
373
;    opendialog draw_window, prep_load, st_1, fname_buf
374
;  st_1:
375
;    and  [mode],not RTF_OPENING
376
;    jmp  still;red
377
;  stilld:
378
;    jmp  still
31 halyavin 379
;---------------------------------------------------------------------
380
 
381
  button:
134 diamond 382
    mcall 17            ; 17 - получить идентификатор нажатой кнопки
31 halyavin 383
 
1515 dunkaist 384
    cmp   ah, 1         ; если нажата кнопка с номером 1,
385
    je    .exit
386
    jmp still
387
 
31 halyavin 388
  .exit:
134 diamond 389
    mcall -1            ; иначе конец программы
1515 dunkaist 390
 
391
 
31 halyavin 392
;---------------------------------------------------------------------
1515 dunkaist 393
;---  MOUSE EVENT PROCESSING  ----------------------------------------
394
;---------------------------------------------------------------------
395
mouse:
396
        mcall   37,7
397
        test    eax,    eax
398
        je      .menu_bar_1;.mouse
399
        jmp     still
400
 
401
 
402
.menu_bar_1:
403
        call    .set_mouse_flag
404
@@:
405
        push    dword menu_data_1       ;mouse event for Menu 1
406
        call    [menu_bar_mouse]
407
        cmp     [menu_data_1.click],dword 1
408
        jne     .menu_bar_2
409
        cmp     [menu_data_1.cursor_out],dword 0
410
        jne     .analyse_out_menu_1
411
        jmp     .menu_bar_1
412
.menu_bar_2:
413
        push    dword menu_data_2
414
        call    [menu_bar_mouse]
415
        cmp     [menu_data_2.click],dword 1
416
        jne     .menu_bar_3
417
        cmp     [menu_data_2.cursor_out],dword 0
418
        jne     .analyse_out_menu_2
419
        jmp     .menu_bar_1
420
.menu_bar_3:
421
        push    dword menu_data_3
422
        call    [menu_bar_mouse]
423
        cmp     [menu_data_3.click],dword 1
424
        jne     .scroll_bar
425
        cmp     [menu_data_3.cursor_out],dword 0
426
        jne     .analyse_out_menu_3
427
        jmp     .menu_bar_1
428
 
429
.set_mouse_flag:
430
        xor     eax,eax
431
        inc     eax
432
        mov     [menu_data_1.get_mouse_flag],eax
433
        mov     [menu_data_2.get_mouse_flag],eax
434
        mov     [menu_data_3.get_mouse_flag],eax
435
        ret
436
 
437
.analyse_out_menu_1:
438
        cmp     [menu_data_1.cursor_out],dword 1
439
        je      key.file_open
440
        cmp     [menu_data_1.cursor_out],dword 2
441
        je      button.exit
442
        jmp     red
443
 
444
.analyse_out_menu_2:
445
        cmp     [menu_data_2.cursor_out],dword 1
446
        je      key.zplus
447
        cmp     [menu_data_2.cursor_out],dword 2
448
        je      key.zminus
449
        cmp     [menu_data_2.cursor_out],dword 3
450
        je      key.incp
451
        cmp     [menu_data_2.cursor_out],dword 4
452
        je      key.decp
453
        cmp     [menu_data_2.cursor_out],dword 5
454
        je      key.alignment
455
        cmp     [menu_data_2.cursor_out],dword 6
456
        je      key.color
457
        jmp     red
458
 
459
.analyse_out_menu_3:
460
        cmp     [menu_data_3.cursor_out],dword 1
461
        je      key.help
462
        jmp     red
463
 
464
.scroll_bar:
1524 dunkaist 465
        cmp     dword[is_scroll_bar_needed], 0
1515 dunkaist 466
        je      still
467
.vertical:
468
        mov     eax,[scroll_bar_data_vertical.max_area]
469
        cmp     eax,[scroll_bar_data_vertical.cur_area]
470
        jbe     still
471
; mouse event for Vertical ScrollBar
472
 
473
        push    dword scroll_bar_data_vertical
474
        call    [scrollbar_ver_mouse]
475
 
476
        call    Set_position
477
 
478
        mov     eax,scroll_bar_data_vertical.redraw
479
        xor     ebx,ebx
480
        cmp     [eax],ebx
481
        je      @f
482
        mov     [eax],ebx
483
        jmp     red
484
@@:
485
        cmp     [scroll_bar_data_vertical.delta2],0
486
        jne     still
487
.other:
488
        jmp     still
489
;---------------------------------------------------------------------
31 halyavin 490
;---  ОПРЕДЕЛЕНИЕ И ОТРИСОВКА ОКНА  ----------------------------------
491
;---------------------------------------------------------------------
492
 
493
draw_window:
494
 
1524 dunkaist 495
    mcall 9, procinfo2, -1
2074 dunkaist 496
    test [procinfo2.wnd_state], 0x04
497
    jz   @f
498
    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
499
    ret
500
  @@:
1524 dunkaist 501
    mov  edx, -1
502
    mov  esi, -1
503
 
504
    mov  eax, [procinfo2.box.width]
1525 dunkaist 505
    cmp  eax, [window_width]
1524 dunkaist 506
     je  @f
507
    mov  [is_scroll_bar_needed],    0
1525 dunkaist 508
    cmp  eax, 140
509
     jnl @f
510
    mov  eax, 140
1524 dunkaist 511
  @@:
1525 dunkaist 512
    mov  edx, eax
513
    mov  [window_width],    eax
1524 dunkaist 514
 
515
    mov  eax, [procinfo2.box.height]
1525 dunkaist 516
    cmp  eax, [window_height]
1524 dunkaist 517
     je  @f
518
    mov  [is_scroll_bar_needed],    0
1525 dunkaist 519
    cmp  eax, 80
520
     jnl @f
521
    mov  eax, 80
1524 dunkaist 522
  @@:
1525 dunkaist 523
    mov  esi, eax
524
    mov  [window_height],   eax
1524 dunkaist 525
 
526
    mcall 67, -1, -1
527
 
1515 dunkaist 528
    mcall 12, 1
529
;    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x805080D0, 0x005080D0
530
;    mcall 4, <8,8>, 0x10DDEEFF, title, titlesize-title
531
    mcall 0, <10,WINW>, <100,WINH>, WIN_COLOR,0x80000000, window_title
2813 leency 532
 
1524 dunkaist 533
;---------------------------------------------
2813 leency 534
    mcall 9, procinfo2, -1
535
 
536
	mcall 48,4
537
	mov [skin_height], eax
538
 
539
	mov  ebx,0*65536-9
540
    add  ebx, [procinfo2.box.width]
541
 
542
	cmp  [is_scroll_bar_needed], 0
543
	je  @f
544
	  sub ebx, SCROLL_WIDTH_SIZE
545
	  dec ebx
546
	@@:
547
 
548
	mov  ecx, 19*65536-23
549
    add  ecx, [procinfo2.box.height]
550
	sub  ecx, [skin_height]
551
 
552
	mov  eax, 13
553
	mov  edx, 0xf0f0f0
554
	int 0x40
555
;---------------------------------------------
1524 dunkaist 556
    cmp  [is_scroll_bar_needed],    0
557
     je  @f
558
    call Set_scroll_position
559
        xor     eax,eax
560
        inc     eax
561
        mov     [scroll_bar_data_vertical.all_redraw],eax
562
; draw for Vertical ScrollBar
563
        push    dword scroll_bar_data_vertical
564
        call    [scrollbar_ver_draw]
565
; reset all_redraw flag
566
        xor     eax,eax
567
        mov     [scroll_bar_data_vertical.all_redraw],eax
568
  @@:
569
;---------------------------------------------
2813 leency 570
	;po-moumu eto govno mamonta
571
 
572
    ;mcall 47,0x30000,isymImplemented,<114,8>, 0x10DDEEFF
573
    ;add  edx,36 shl 16
574
    ;mcall ,,isymMax
31 halyavin 575
    add  edx,40 shl 16
576
    mov  esi,0x104e00e7;0x10f27840
577
    cmp  dword[fileinfo.name],N_A
578
    jne  .noNA
579
    mov  esi,0x10ff0000
580
  .noNA:
1524 dunkaist 581
;    mcall 4,edx,esi,fileinfo.name,[fname_size]
2813 leency 582
    mcall 9,prcinfo,-1
31 halyavin 583
    and  [mode],not RTF_TOEOF
584
    mov  ebx,[edi+42]
585
    cmp  ebx,[wSave]
134 diamond 586
    je   .nochg
31 halyavin 587
  .chg:
588
    mov  [wSave],ebx
134 diamond 589
    or   [mode],RTF_TOEOF
31 halyavin 590
    and  [HDoc],0
591
    and  [line_count],0
1515 dunkaist 592
;    mov  [HClick],-100
31 halyavin 593
  .nochg:
1195 diamond 594
 
1515 dunkaist 595
;---------------------------------------------
1524 dunkaist 596
    call  Set_scroll_position
1195 diamond 597
 
2813 leency 598
;---------------------------------------------
1515 dunkaist 599
    mov ebx, dword[prcinfo+0x3E]
600
    mcall     38, , 65536*18+18, 0x8b8b89
601
    inc ebx
602
    mcall     13, , 65536*0+18, 0xe9e9e2
603
;---------------------------------------------
604
; draw for Menu 1
605
        push    dword menu_data_1
606
        call    [menu_bar_draw]
607
; draw for Menu 2
608
        push    dword menu_data_2
609
        call    [menu_bar_draw]
610
; draw for Menu 3
611
        push    dword menu_data_3
612
        call    [menu_bar_draw]
613
;---------------------------------------------
1195 diamond 614
 
2813 leency 615
    sub  dword[prcinfo+42],2*LMARGIN+SCROLL_WIDTH_SIZE
1515 dunkaist 616
    sub  dword[prcinfo+46],CHARH+25
617
 
31 halyavin 618
 if GUTTER eq 1
619
    mov  ebx,LMARGIN shl 16+20
620
    mov  ecx,20
621
    mov  eax,4
622
    mov  edx,arrow
623
    mov  esi,1
624
  .loop1:
625
    push ecx
626
    mcall ,,0xff0000
627
    pop  ecx
628
    add  ebx,50 shl 16
629
    loop .loop1
630
 end if
631
 if MODE eq RTF
632
    test [mode],RTF_OPENING
633
    jne  .ex
634
    and  [mode],not (RTF_BOTTOM);+RTF_TOEOF)
635
    mov  [colorptr],colortbl
636
    mov  eax,DEFCOLOR
637
    mov  edi,colortbl
638
    mov  ecx,16
639
    rep  stosd
640
    xor  eax,eax
641
    mov  [cGroup],eax
642
    mov  edi,Chp
643
    mov  ecx,SIZE_save
644
    rep  stosb
645
    mov  ax,[top]
646
    mov  word[Free+6],10
647
    mov  word[Free+4],ax
648
    mov  esi,I_END
649
    call RtfParse
1515 dunkaist 650
;    dpd  eax
651
;    dps  'Lines='
31 halyavin 652
    mov  eax,[line_count]
1515 dunkaist 653
;    dpd  eax
654
;    newline
31 halyavin 655
;    movzx  eax,word[Free+4]
656
;    dpd  eax
657
    mov  eax,dword[prcinfo+42]
658
    mov  edx,WIN_COLOR
659
    call draw_progress
660
if BENCH eq 1
661
    mcall 26,9
662
    sub  eax,[bench]
1515 dunkaist 663
;    dps  <13,10,'Bench='>
664
;    dpd  eax
31 halyavin 665
end if
666
 else
667
    mov  [char],0
668
    mov  ebx,10 shl 16+TOP
669
    mov  ecx,16
670
  .l0:
671
    push ecx
672
    mov  ecx,16
673
  .l1:
674
    push ecx
675
  if RENDER eq BGI
676
    mov  edx,char
677
    mov  ecx,0x48000000
678
    mov  esi,1
679
    BGIfont_Outtext
680
  else
681
    mcall 4,,0x10000000,char,1
682
  end if
683
    pop  ecx
684
    inc  [char]
685
    add  ebx,(CHARW+3) shl 16
686
    loop .l1
687
    pop  ecx
688
    add  ebx,CHARH+2
689
    and  ebx,0x0000ffff
690
    add  ebx,10 shl 16
691
    loop .l0
692
 end if
693
 .ex:
1515 dunkaist 694
call Set_position
695
;---------------------------------------------
1524 dunkaist 696
    cmp  dword[is_scroll_bar_needed], 0
1515 dunkaist 697
     je  @f
698
        xor     eax,eax
699
        inc     eax
700
        mov     [scroll_bar_data_vertical.all_redraw],eax
701
; draw for Vertical ScrollBar
702
        push    dword scroll_bar_data_vertical
703
        call    [scrollbar_ver_draw]
704
; reset all_redraw flag
705
        xor     eax,eax
706
        mov     [scroll_bar_data_vertical.all_redraw],eax
707
  @@:
708
;---------------------------------------------
709
    mcall 12, 2
710
    ret
31 halyavin 711
 
1515 dunkaist 712
;---------------------------------------------------------------------
713
Set_position:
714
    mov  eax, dword[prcinfo+46]
715
    cmp  eax, [HDoc]
1524 dunkaist 716
    mov  dword[is_scroll_bar_needed], 0
1515 dunkaist 717
     jnl .quit
1524 dunkaist 718
    mov  dword[is_scroll_bar_needed], 1
1515 dunkaist 719
 
720
    mov  eax, [scroll_bar_data_vertical.max_area]
721
    mul  dword[prcinfo+46]
722
    div  dword[HDoc]
723
    cmp  eax, [scroll_bar_data_vertical.max_area]
724
    mov  dword[scroll_bar_data_vertical.cur_area],eax
725
     jng @f
726
    mov  eax, [scroll_bar_data_vertical.max_area]
727
    mov  dword[scroll_bar_data_vertical.cur_area], eax
728
  @@:
729
    mov eax, [HDoc]
730
    cmp eax, dword[prcinfo+46]
731
    sub eax, dword[prcinfo+46]
1524 dunkaist 732
    add eax, 20                    ; height of clear area under text when you are at the end of document
1515 dunkaist 733
     jg @f
734
    mov eax, 0
735
  @@:
736
    mul [scroll_bar_data_vertical.position]
737
    mov ebx, [scroll_bar_data_vertical.max_area]
738
    sub ebx, [scroll_bar_data_vertical.cur_area]
739
    div ebx
740
 
741
    mov dword[top], TOP
742
    sub dword[top], eax
743
 
744
  .quit:
745
    ret
746
;---------------------------------------------------------------------
1524 dunkaist 747
Set_scroll_position:
748
    mcall 9, procinfo2, -1
749
    mov eax, dword[procinfo2+0x3E]
2813 leency 750
    sub eax, SCROLL_WIDTH_SIZE
1524 dunkaist 751
    mov word[scroll_bar_data_vertical.start_x], ax
752
 
753
    mov eax, dword[procinfo2+0x42]
754
    sub eax, 17
755
    mov word[scroll_bar_data_vertical.size_y], ax
756
 
757
    ret
758
;---------------------------------------------------------------------
759
 
31 halyavin 760
if GUTTER eq 1
761
   arrow db 0x19
762
end if
763
;---------------------------------------------------------------------
764
;---  ДАННЫЕ ПРОГРАММЫ  ----------------------------------------------
765
;---------------------------------------------------------------------
766
 
767
; интерфейс программы многоязычный
768
;  Вы можете задать язык в MACROS.INC (lang fix язык)
485 heavyiron 769
 
2813 leency 770
window_title:           db      'RtfRead v1.4',0
1524 dunkaist 771
is_scroll_bar_needed    dd      0x0
1525 dunkaist 772
window_width            dd      0x0
773
window_height           dd      0x0
2813 leency 774
skin_height             dd      0x0
1418 mario79 775
;---------------------------------------------------------------------
1512 mario79 776
l_libs_start:
777
 
778
library01  l_libs system_dir_ProcLib+9, cur_dir_path, library_path, system_dir_ProcLib, \
779
err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
780
 
1524 dunkaist 781
library02  l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \
1515 dunkaist 782
err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i
783
 
1512 mario79 784
end_l_libs:
785
;---------------------------------------------------------------------
1515 dunkaist 786
system_dir_ProcLib      db '/sys/lib/proc_lib.obj',0
787
system_dir_Boxlib       db '/sys/lib/box_lib.obj',0
1512 mario79 788
 
789
head_f_i:
1515 dunkaist 790
head_f_l                db 'error',0
1512 mario79 791
 
1515 dunkaist 792
err_message_found_lib1  db 'box_lib.obj - Not found!',0
793
err_message_found_lib2  db 'proc_lib.obj - Not found!',0
1512 mario79 794
 
1515 dunkaist 795
err_message_import1     db 'box_lib.obj - Wrong import!',0
796
err_message_import2     db 'proc_lib.obj - Wrong import!',0
1512 mario79 797
 
798
;---------------------------------------------------------------------
799
align 4
800
ProcLib_import:
1515 dunkaist 801
OpenDialog_Init         dd aOpenDialog_Init
802
OpenDialog_Start        dd aOpenDialog_Start
803
;OpenDialog__Version    dd aOpenDialog_Version
1512 mario79 804
        dd      0
805
        dd      0
1515 dunkaist 806
aOpenDialog_Init        db 'OpenDialog_init',0
807
aOpenDialog_Start       db 'OpenDialog_start',0
808
;aOpenDialog_Version    db 'Version_OpenDialog',0
1512 mario79 809
;---------------------------------------------------------------------
1418 mario79 810
OpenDialog_data:
1515 dunkaist 811
.type                   dd 0
812
.procinfo               dd procinfo ;+4
813
.com_area_name          dd communication_area_name ;+8
814
.com_area               dd 0 ;+12
815
.opendir_pach           dd temp_dir_pach ;+16
816
.dir_default_pach       dd communication_area_default_pach ;+20
817
.start_path             dd open_dialog_path ;+24
818
.draw_window            dd draw_window ;+28
819
.status                 dd 0 ;+32
820
.openfile_pach          dd fname_buf ;+36
821
.filename_area          dd 0    ;+40
822
.filter_area            dd Filter
1582 mario79 823
.x:
824
.x_size			dw 420 ;+48 ; Window X size
825
.x_start		dw 10 ;+50 ; Window X position
826
.y:
827
.y_size			dw 320 ;+52 ; Window y size
828
.y_start		dw 10 ;+54 ; Window Y position
31 halyavin 829
 
1418 mario79 830
communication_area_name:
1515 dunkaist 831
        db 'FFFFFFFF_open_dialog',0
1418 mario79 832
open_dialog_path:
1702 Lrz 833
if __nightbuild eq yes
834
    db '/sys/MANAGERS/opendial',0
835
else
836
    db '/sys/File Managers/opendial',0
837
end if
1418 mario79 838
communication_area_default_pach:
1515 dunkaist 839
        db '/rd/1',0
1418 mario79 840
 
841
Filter:
1436 mario79 842
dd Filter.end - Filter
843
.1:
1418 mario79 844
db 'RTF',0
845
.end:
846
db 0
847
;---------------------------------------------------------------------
139 diamond 848
attrinfo:
849
        dd      5
850
        dd      0
851
        dd      0
852
        dd      0
853
        dd      fileattr
854
        db      0
855
        dd      fileinfo.name
856
 
31 halyavin 857
fileinfo:
858
  dd 0
859
.block:
860
  dd 0
139 diamond 861
  dd 0
31 halyavin 862
.size  dd 1
863
  dd I_END
864
.name:
1515 dunkaist 865
 
31 halyavin 866
;  db '/HD/1/RTF/texts/index_ru.RTF',0
867
 
868
   rb  256-($-.name)
869
;---------------------------------------------------------------------
1515 dunkaist 870
align   4
871
Box_lib_import:
872
 
873
menu_bar_draw           dd aMenu_bar_draw
874
menu_bar_mouse          dd aMenu_bar_mouse
875
 
876
scrollbar_ver_draw      dd aScrollbar_ver_draw
877
scrollbar_ver_mouse     dd aScrollbar_ver_mouse
878
 
879
        dd 0
880
        dd 0
881
 
882
aMenu_bar_draw          db 'menu_bar_draw',0
883
aMenu_bar_mouse         db 'menu_bar_mouse',0
884
;aVersion_menu_bar       db 'version_menu_bar',0
885
 
886
aScrollbar_ver_draw     db 'scrollbar_v_draw',0
887
aScrollbar_ver_mouse    db 'scrollbar_v_mouse',0
888
;---------------------------------------------------------------------
889
align   4
890
menu_data_1:
891
.type:          dd 0    ;+0
892
.x:
893
.size_x         dw 40   ;+4
894
.start_x        dw 2    ;+6
895
.y:
896
.size_y         dw 15   ;+8
897
.start_y        dw 2    ;+10
898
.text_pointer:  dd menu_text_area       ;0      ;+12
899
.pos_pointer:   dd menu_text_area.1     ;0      ;+16
900
.text_end       dd menu_text_area.end   ;0      ;+20
901
.mouse_pos      dd 0    ;+24
902
.mouse_keys     dd 0    ;+28
903
.x1:
904
.size_x1        dw 40   ;+32
905
.start_x1       dw 2    ;+34
906
.y1:
907
.size_y1        dw 100  ;+36
908
.start_y1       dw 18   ;+38
909
.bckg_col       dd 0xeeeeee     ;+40
910
.frnt_col       dd 0xff ;+44
911
.menu_col       dd 0xffffff     ;+48
912
.select         dd 0    ;+52
913
.out_select     dd 0    ;+56
914
.buf_adress     dd 0    ;+60
915
.procinfo       dd 0    ;+64
916
.click          dd 0    ;+68
917
.cursor         dd 0    ;+72
918
.cursor_old     dd 0    ;+76
919
.interval       dd 16   ;+80
920
.cursor_max     dd 0    ;+84
921
.extended_key   dd 0    ;+88
922
.menu_sel_col   dd 0x00cc00     ;+92
923
.bckg_text_col  dd 0    ;+96
924
.frnt_text_col  dd 0xffffff     ;+100
925
.mouse_keys_old dd 0    ;+104
926
.font_height    dd 8    ;+108
927
.cursor_out     dd 0    ;+112
928
.get_mouse_flag dd 0    ;+116
929
 
930
menu_text_area:
931
        db 'File',0
932
.1:
933
        db 'Open',0
934
        db 'Exit',0
935
.end:
936
        db 0
937
;---------------------------------------------------------------------
938
align   4
939
menu_data_2:
940
.type:          dd 0    ;+0
941
.x:
942
.size_x         dw 40   ;+4
943
.start_x        dw 43   ;+6
944
.y:
945
.size_y         dw 15   ;+8
946
.start_y        dw 2    ;+10
947
.text_pointer:  dd menu_text_area_2     ;0      ;+12
948
.pos_pointer:   dd menu_text_area_2.1   ;0      ;+16
949
.text_end       dd menu_text_area_2.end ;0      ;+20
950
.mouse_pos      dd 0    ;+24
951
.mouse_keys     dd 0    ;+28
952
.x1:
953
.size_x1        dw 50   ;+32
954
.start_x1       dw 43   ;+34
955
.y1:
956
.size_y1        dw 100  ;+36
957
.start_y1       dw 18   ;+38
958
.bckg_col       dd 0xeeeeee     ;+40
959
.frnt_col       dd 0xff ;+44
960
.menu_col       dd 0xffffff     ;+48
961
.select         dd 0    ;+52
962
.out_select     dd 0    ;+56
963
.buf_adress     dd 0    ;+60
964
.procinfo       dd 0    ;+64
965
.click          dd 0    ;+68
966
.cursor         dd 0    ;+72
967
.cursor_old     dd 0    ;+76
968
.interval       dd 16   ;+80
969
.cursor_max     dd 0    ;+84
970
.extended_key   dd 0    ;+88
971
.menu_sel_col   dd 0x00cc00     ;+92
972
.bckg_text_col  dd 0    ;       +96
973
.frnt_text_col  dd 0xffffff     ;+100
974
.mouse_keys_old dd 0    ;+104
975
.font_height    dd 8    ;+108
976
.cursor_out     dd 0    ;+112
977
.get_mouse_flag dd 0    ;+116
978
 
979
menu_text_area_2:
980
        db 'View',0
981
.1:
982
        db 'Zoom +',0
983
        db 'Zoom -',0
1524 dunkaist 984
        db ' > >',0
985
        db ' << ',0
1515 dunkaist 986
        db 'Align',0
987
        db 'Color',0
988
.end:
989
        db 0
990
;---------------------------------------------------------------------
991
align   4
992
menu_data_3:
993
.type:          dd 0    ;+0
994
.x:
995
.size_x         dw 40   ;+4
996
.start_x        dw 84   ;+6
997
.y:
998
.size_y         dw 15   ;+8
999
.start_y        dw 2    ;+10
1000
.text_pointer:  dd menu_text_area_3     ;0      ;+12
1001
.pos_pointer:   dd menu_text_area_3.1   ;0      ;+16
1002
.text_end       dd menu_text_area_3.end ;0      ;+20
1003
.mouse_pos      dd 0    ;+24
1004
.mouse_keys     dd 0    ;+28
1005
.x1:
1006
.size_x1        dw 40   ;+32
1007
.start_x1       dw 84   ;+34
1008
.y1:
1009
.size_y1        dw 100  ;+36
1010
.start_y1       dw 18   ;+38
1011
.bckg_col       dd 0xeeeeee     ;+40
1012
.frnt_col       dd 0xff ;+44
1013
.menu_col       dd 0xffffff     ;+48
1014
.select         dd 0    ;+52
1015
.out_select     dd 0    ;+56
1016
.buf_adress     dd 0    ;+60
1017
.procinfo       dd 0    ;+64
1018
.click          dd 0    ;+68
1019
.cursor         dd 0    ;+72
1020
.cursor_old     dd 0    ;+76
1021
.interval       dd 16   ;+80
1022
.cursor_max     dd 0    ;+84
1023
.extended_key   dd 0    ;+88
1024
.menu_sel_col   dd 0x00cc00     ;+92
1025
.bckg_text_col  dd 0    ;       +96
1026
.frnt_text_col  dd 0xffffff     ;+100
1027
.mouse_keys_old dd 0    ;+104
1028
.font_height    dd 8    ;+108
1029
.cursor_out     dd 0    ;+112
1030
.get_mouse_flag dd 0    ;+116
1031
 
1032
menu_text_area_3:
1033
        db 'Help',0
1034
.1:
1035
        db 'Home',0
1036
.end:
1037
        db 0
1038
;---------------------------------------------------------------------
1039
align   4
1040
scroll_bar_data_vertical:
1041
.x:
2813 leency 1042
.size_x         dw SCROLL_WIDTH_SIZE;+0
1515 dunkaist 1043
.start_x        dw WINW-25  ;+2
1044
.y:
1045
.size_y         dw WINH-45  ;+4
1046
.start_y        dw 19   ;+6
2813 leency 1047
.btn_high       dd SCROLL_WIDTH_SIZE    ;+8
1048
.type           dd 0    ;+12
1515 dunkaist 1049
.max_area       dd 300       ;+16
1050
.cur_area       dd 50   ;+20
1051
.position       dd 0    ;+24
1052
.bckg_col       dd 0xAAAAAA     ;+28
1053
.frnt_col       dd 0xCCCCCC     ;+32
1054
.line_col       dd 0    ;+36
1055
.redraw         dd 0    ;+40
1056
.delta          dw 0    ;+44
1057
.delta2         dw 0    ;+46
1058
.run_x:
1059
.r_size_x       dw 0    ;+48
1060
.r_start_x      dw 0    ;+50
1061
.run_y:
1062
.r_size_y       dw 0    ;+52
1063
.r_start_y      dw 0    ;+54
1064
.m_pos          dd 0    ;+56
1065
.m_pos_2        dd 0    ;+60
1066
.m_keys         dd 0    ;+64
1067
.run_size       dd 0    ;+68
1068
.position2      dd 0    ;+72
1069
.work_size      dd 0    ;+76
1070
.all_redraw     dd 0    ;+80
1071
.ar_offset      dd AR_OFFSET   ;+84
2805 dunkaist 1072
 
1515 dunkaist 1073
;---------------------------------------------------------------------
2805 dunkaist 1074
;blind db ?
1075
if RENDER eq PIX
1076
;  rd 2
1077
  Free rd 9
1078
else
1079
if RENDER eq BGI
1080
  FreeFontscale dd 0.07
1081
else
1082
  Zoomscale dd 1.15
1083
  FreeFontscale dd 0.04
1084
end if
1085
  Free BGIfree FONT_NAME,0,0,1.0,1.0,char,1,0x44000000,0
1086
end if
1524 dunkaist 1087
I_END0:
2805 dunkaist 1088
fname_buf:
1089
        rb      1024+16
1090
fileattr rd 40/4
1091
if BENCH eq 1
1092
  bench dd ?
1093
end if
1094
tail dd ?
1095
cGroup dd ?
1096
Chp:
1097
  CHP
1098
Pap:
1099
  PAP
1100
Sep:
1101
  SEP
1102
Dop:
1103
  DOP
1104
rds db ?
1105
ris db ?
1106
cbBin dd ?
1107
lParam dd ?
1108
fSkipDestIfUnk db ?
1109
mode dd ?
1110
curheight dw ?
1111
maxheight dw ?
1112
RetroBlock dd ?
1113
RetroSave:
1114
  SAVE
1115
prcinfo rb 1024
1116
RetroPtr dd ?
1117
colorptr dd ?
1118
colortbl rd 16
1119
ct_end:
1120
fname_size dd ?
1121
max_block dd ?
1122
cur_block dd ?
1123
HDoc dd ?
1124
;HClick dd ?
1125
top dw ?
1126
line_count dd ?
1127
par_count  dd ?
1128
char db ?
1129
pitch db ?
1130
wSave dd ?
1131
RetroXY dd ?
1132
RetroGroup dd ?
1133
 
1134
save_stack:
1135
rb RTFSTACKSIZE
1136
save_limit:
1137
rb BGIFONTSIZE
1138
 
1139
listptr dd ?
1140
szKeyword rb 31
1141
szParameter rb 21
1142
block_end dd ?
1143
 
1144
;---------------------------------------------------------------------
134 diamond 1145
I_END:                             ; метка конца программы
485 heavyiron 1146
 
1147
procinfo process_information
31 halyavin 1148
rb RTFSIZE
1149
esp1:
1150
rb ESPSIZE
1524 dunkaist 1151
procinfo2 process_information
1418 mario79 1152
;---------------------------------------------------------------------
1153
temp_dir_pach:
1154
        rb 4096
1512 mario79 1155
cur_dir_path:
1515 dunkaist 1156
        rb 4096
1512 mario79 1157
library_path:
1515 dunkaist 1158
        rb 4096
1418 mario79 1159
;---------------------------------------------------------------------
1524 dunkaist 1160
    rb ESPSIZE                      ;stack
134 diamond 1161
esp_end:
1524 dunkaist 1162
sys_mem: