Subversion Repositories Kolibri OS

Rev

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