Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
122 diamond 1
;-----------------------------------------------------------------------------
31 halyavin 2
; project name:      TINYPAD
178 heavyiron 3
; compiler:          flat assembler 1.67.1
4
; memory to compile: 2.0/7.0 MBytes (without/with size optimizations)
5
; version:           4.0.3
6
; last update:       2006-08-28 (Aug 28, 2006)
7
; minimal kernel:    revision #138 (svn://kolibrios.org/kernel)
122 diamond 8
;-----------------------------------------------------------------------------
9
; originally by:     Ville Michael Turjanmaa >> villemt@aton.co.jyu.fi
10
; maintained by:     Ivan Poddubny           >> ivan-yar@bk.ru
11
;                    Mike Semenyako          >> mike.dld@gmail.com
12
;-----------------------------------------------------------------------------
13
; TODO:
178 heavyiron 14
;   - optimize drawing (reduce flickering)
15
;   - optimize memory usage (allocate only needed amount, not static 3 Mbytes)
16
;   - add block selection ability, undo action, goto position
17
;   - working with multiple files (add tabs)
18
;   - improve window drawing with small dimensions
19
;   - other bugfixes and speed/size optimizations
122 diamond 20
;
31 halyavin 21
; HISTORY:
178 heavyiron 22
; 4.0.3 (mike.dld)
23
;   bug-fixes:
24
;     - 1-char selection if pressing  out of real line length
25
;     - fault in `writepos`, added call to function 9
26
;     - main menu items weren't highlighted if popup opened and cursor
27
;       isn't in menu item's area
28
;     - statusbar and textboxes drawing fixes (wrong colors)
29
;     - perform no redraw while pressing Shift, Ctrl, Alt keys
30
;     - data length from DOCPAK in string representation (fix by diamond)
31
;   changes:
32
;     - function 70 instead of 58 for files loading/saving
33
;     - clientarea-relative drawing (less code)
34
;     - every line's dword is now splitted into 2 words;
35
;       low word - line block length, so max line length is 65535 now
36
;       high word - various flags. for now, only 2 of 16 bits are used:
37
;         if bit #0 is set, line was modified since file open
38
;         if bit #1 is set, line was saved after last modification
39
;       high word could also be further used for code collapsing and different
40
;         line marking features (breakpoints, errors, bookmarks, etc.)
41
;   new features:
42
;     - line markers for modified and saved lines
43
;     - status messages for various actions
122 diamond 44
; 4.0.2 (mike.dld)
45
;   bug-fixes:
46
;     - program terminates if started with parameters (fine for DOCPAK)
47
; 4.0.1 (mike.dld)
48
;   bug-fixes:
49
;     - unable to run program after exiting from main menu (Alt+X)
50
;   new features:
51
;     - integration with DOCPAK
52
; 4.0 (mike.dld)
53
;   bug-fixes:
54
;     - main menu popups' "on show" was called only for first shown popup
55
;     - clear selection on left/right arrow keys
56
;   new features:
57
;     - "replace" dialog (w/o "skip", "replace all")
58
;     - line numbers display
59
;     - options (except "appearance" and "smart tabulation")
60
;     - options saving (colors, window position, "Options" popup triggers)
61
; 4.0 beta 2 (mike.dld)
62
;   bug-fixes:
63
;     - unable to start if /rd/1/example.asm is missing (from Halyavin)
64
;     - clicking on menu items draws main window in popup (from Rohan)
65
;     - passed parameters aren't taken into account (from Mario79)
66
;     - background isn't erased if text lines < screen lines after
67
;       selection deletion (from Rohan)
68
; 4.0 beta 1 (mike.dld)
69
;   menu bar and popup menu;
70
;     removed buttons from the top and input fields from the bottom since
71
;     now they're accesible through main/popup menu;
72
;   improved keyboard handling (using 66th function);
73
;     support for almost all FASMW keyboard shourtcuts;
74
;   added text selection ability, standard selection operations
75
;     (copy,cut,paste);
76
;   new integrated dialogs (open, save, find)
77
;   fix to collapse SPACEs into TABs only for *.asm and *.inc files
31 halyavin 78
; 3.78a (mike.dld)
122 diamond 79
;   fixed termination while typing in x positions higher than (line_length+10);
31 halyavin 80
;   improved drawing on small heights
122 diamond 81
;     don't draw window while its height = 0 (Kolibri "minimize" support)
31 halyavin 82
; 3.78 (mike.dld)
83
;   now lines may be of ANY length;
84
;     optimized memory usage (less memory for internal file representation)
85
;       after loading file, it's internal size equals to its real size
86
;       plus 14 bytes for each line (4 bytes for line length
122 diamond 87
;         and 10 spaced to the end - to reduce data relocations count);
31 halyavin 88
;     completely rewritten keyboard handling;
89
;     added horizontal scrollbar;
90
;   all line feed formats are supported: WIN(CRLF),*NIX(LF),MAC(CR);
91
;   etc.
92
; 3.77 (mike.dld)
93
;   changed save_string to collapse SPACEs into TABs;
94
;   rewrote drawfile from scratch (speed++)
178 heavyiron 95
;     through some drawing improvements  needed
31 halyavin 96
;     (some checkups to reduce flickering);
97
;   writepos (size--);
98
;   fixed drawing window while height < 100px, and for non-asm files;
99
;   several small fixes; speed/size optimizations
100
; 3.76 (mike.dld)
101
;   changed loadfile/loadhdfile to expand TABs into SPACEs;
102
;   changed TAB,ENTER,DELETE,BSPACE keys behaviour (rewritten from scratch);
103
;   vertical scrollbar;
104
;   extra window resizing capabilities (added a couple of constants);
105
;   completely new text cursor management & moving text cursor with mouse;
106
;   improved search function, moving cursor to beginning of text found;
122 diamond 107
;   adjustable max line width (change LINE_WIDTH & recompile) // (obsolet)
31 halyavin 108
; 3.75a
109
;   fixed converting char to upper case in read_string
110
; 3.75
111
;   rewrote save_file from scratch; bugfix in loadfile;
112
; 3.74
113
;   optimisation
114
; 3.73
115
;   completly new load_file function
116
; 3.72
117
;   speed++
118
; 3.71
119
;   error beep
120
; 3.6,3.7:
121
;   many bugs fixed
122
;   simple toolbar
123
;   compile, run applications from TINYPAD, all fasm output is in debug board
124
;   TAB button
125
;   auto-indent
126
;   Ctrl+L - insert comment string
122 diamond 127
;-----------------------------------------------------------------------------
31 halyavin 128
; Memory 0x300000:
122 diamond 129
;   stack for popup  0x00dff0 -
130
;   stack for help   0x00eff0 -
131
;   stack            0x00fff0 -
132
;   load position    0x010000 +
133
;   edit area        0x080000 +
134
;   copy/paste area  0x2f0000 +
135
;-----------------------------------------------------------------------------
31 halyavin 136
 
178 heavyiron 137
include 'lang.inc'
31 halyavin 138
include 'macros.inc' ; useful stuff
178 heavyiron 139
;include 'proc32.inc'
122 diamond 140
include 'tinypad.inc'
178 heavyiron 141
;purge mov,add,sub            ;  SPEED
31 halyavin 142
 
122 diamond 143
header '01',1,@CODE,TINYPAD_END,AREA_ENDMEM,MAIN_STACK,@PARAMS,self_path
31 halyavin 144
 
122 diamond 145
;include 'debug.inc'
31 halyavin 146
 
122 diamond 147
ASEPC     = '-'           ; separator character (char)
148
ATOPH     = POP_IHEIGHT+2 ; menu bar height (pixels)
149
;OLEFT    = 50+1          ; left offset (pixels)        !!! don't change !!!
150
SCRLW     = 16            ; scrollbar widht/height (pixels)
151
ATABW     = 8             ; tab width (chars)
152
LINEH     = 10            ; line height (pixels)
153
PATHL     = 255           ; maximum path length (chars) !!! don't change !!!
154
AMINS     = 8             ; minimal scroll thumb size (pixels)
178 heavyiron 155
LCHGW     = 2             ; changed/saved marker width
31 halyavin 156
 
122 diamond 157
STATH     = 14            ; status bar height
31 halyavin 158
 
122 diamond 159
MEV_LDOWN = 1
160
MEV_LUP   = 2
161
MEV_RDOWN = 3
162
MEV_RUP   = 4
163
MEV_MOVE  = 5
164
 
31 halyavin 165
;-----------------------------------------------------------------------------
122 diamond 166
section @OPTIONS ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 167
;-----------------------------------------------------------------------------
168
 
122 diamond 169
label color_tbl dword
170
  RGB(  0,  0,  0) ; RGB(  0,  0,  0) ; RGB(  0,  0,  0) ; text
171
  RGB(  0,144,  0) ; RGB(  0,144,  0) ; RGB(  0,160,  0) ; numbers
172
  RGB(176,  0,  0) ; RGB(160,  0,  0) ; RGB(  0,128,255) ; strings
173
  RGB(128,128,128) ; RGB(144,144,144) ; RGB(160,160,160) ; comments
174
  RGB( 48, 48,240) ; RGB( 48, 48,240) ; RGB(255,  0,  0) ; symbols
175
  RGB(255,255,255) ; RGB(224,224,224) ; RGB(255,255,255) ; background
176
  RGB(255,255,255) ; RGB(255,255,255) ; RGB(255,255,255) ; selection text
177
  RGB( 10, 36,106) ; RGB(  0,  0,128) ; RGB(  0, 64,128) ; selection background
178 heavyiron 178
  RGB(  0,255,  0) ; modified line marker
179
  RGB(255,255,  0) ; saved line marker
31 halyavin 180
 
122 diamond 181
ins_mode db 1
31 halyavin 182
 
122 diamond 183
options  db OPTS_AUTOINDENT+OPTS_OPTIMSAVE+OPTS_SMARTTAB
31 halyavin 184
 
122 diamond 185
mainwnd_pos:
186
  .x dd 100
187
  .y dd 75
188
  .w dd 6*80+6+SCRLW+5
189
  .h dd 402
31 halyavin 190
 
122 diamond 191
;-----------------------------------------------------------------------------
192
section @CODE ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
193
;-----------------------------------------------------------------------------
31 halyavin 194
 
122 diamond 195
;       fninit
31 halyavin 196
 
178 heavyiron 197
;        stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_left,50
198
;        mov     [mainwnd_pos.x],eax
199
;        stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_top,50
200
;        mov     [mainwnd_pos.y],eax
201
;        stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_right,350
202
;        sub     eax,[mainwnd_pos.x]
203
;        mov     [mainwnd_pos.w],eax
204
;        stdcall ini.get_int,finfo_ini,ini_sec_window,ini_window_bottom,450
205
;        sub     eax,[mainwnd_pos.y]
206
;        mov     [mainwnd_pos.h],eax
207
 
122 diamond 208
        cld
209
        mov     edi,@UDATA
210
        mov     ecx,@PARAMS-@UDATA
211
        mov     al,0
212
        rep     stosb
31 halyavin 213
 
178 heavyiron 214
	inc	[do_not_draw]
215
 
122 diamond 216
        mov     [left_ofs],40+1
217
        mov     [f_info+4],0
218
        mov     [f_info+12],AREA_TEMP
219
        mov     [f_info+16],AREA_EDIT-AREA_TEMP
31 halyavin 220
 
122 diamond 221
        mov     esi,s_example
222
        mov     edi,tb_opensave.text
223
        mov     ecx,s_example.size
224
        mov     [tb_opensave.length],cl
225
        rep     movsb
31 halyavin 226
 
122 diamond 227
        mov     esi,s_still
228
        mov     edi,s_search
229
        mov     ecx,s_still.size
230
        mov     [s_search.size],ecx
231
        rep     movsb
31 halyavin 232
 
122 diamond 233
        cmp     byte[@PARAMS],0
234
        jz      no_params
31 halyavin 235
 
122 diamond 236
;// Willow's code to support DOCPAK [
31 halyavin 237
 
122 diamond 238
        cmp     byte[@PARAMS],'*'
239
        jne     .noipc
178 heavyiron 240
 
241
;// diamond [ (convert size from decimal representation to dword)
242
;--     mov     edx,dword[@PARAMS+1]
243
        mov     esi,@PARAMS+1
244
        xor     edx,edx
245
        xor     eax,eax
246
    @@: lodsb
247
        test    al,al
122 diamond 248
        jz      @f
178 heavyiron 249
        lea     edx,[edx*4+edx]
250
        lea     edx,[edx*2+eax-'0']
122 diamond 251
        jmp     @b
178 heavyiron 252
    @@:
253
;// diamond ]
254
 
122 diamond 255
        add     edx,20
256
        mcall   60,1,AREA_TEMP-16 ; 0x10000-16
257
        mov     dword[AREA_TEMP-16+4],8 ; [0x10000-16+4],8
258
        mcall   40,1000000b
259
        mcall   23,200
260
        cmp     eax,7
261
        jne     key.alt_x.close  ; ¤Єю эр mcall -1 ьхЄър
262
        mov     esi,AREA_TEMP-16 ; 0x10000-16
263
        mov     byte[esi],1
264
        mov     eax,[esi+12]
265
        inc     eax
266
        call    load_file.file_found
267
        jmp     @f
268
  .noipc:
31 halyavin 269
 
122 diamond 270
;// Willow's code to support DOCPAK ]
31 halyavin 271
 
122 diamond 272
    ; parameters are at @PARAMS
273
        mov     esi,@PARAMS
274
        mov     edi,tb_opensave.text
275
        mov     ecx,PATHL
276
        rep     movsb
277
        mov     edi,tb_opensave.text
278
        mov     ecx,PATHL
279
        xor     al,al
280
        repne   scasb
281
        jne     key.alt_x.close
282
        lea     eax,[edi-tb_opensave.text-1]
283
        mov     [tb_opensave.length],al
31 halyavin 284
 
122 diamond 285
  no_params:
286
        call    btn.load_file;do_load_file
287
        jnc     @f
288
        call    new_file
31 halyavin 289
 
290
    @@:
178 heavyiron 291
	dec	[do_not_draw]
122 diamond 292
        mcall   66,1,1
293
        mcall   40,00100111b
178 heavyiron 294
red:
295
	call    drawwindow
296
	call	check_inv_all.skip_check
31 halyavin 297
 
122 diamond 298
;-----------------------------------------------------------------------------
31 halyavin 299
 
122 diamond 300
still:
301
       call    writepos ; write current position & number of strings
31 halyavin 302
 
122 diamond 303
  .skip_write:
304
        mcall   10;23,50; wait here until event
305
        cmp     [main_closed],0
306
        jne     key.alt_x
307
        dec     eax     ; redraw ?
308
        jz      red
309
        dec     eax     ; key ?
310
        jz      key
311
        dec     eax     ; button ?
312
        jz      button
313
        sub     eax,3   ; mouse ?
314
        jz      mouse
31 halyavin 315
 
122 diamond 316
        jmp     still.skip_write
31 halyavin 317
 
122 diamond 318
;-----------------------------------------------------------------------------
319
func start_fasm ;/////////////////////////////////////////////////////////////
320
;-----------------------------------------------------------------------------
31 halyavin 321
; BL = run after compile
122 diamond 322
;-----------------------------------------------------------------------------
323
        cmp     [asm_mode],0
324
        jne     @f
325
        ret
326
    @@: mov     esi,f_info.path ; s_fname
327
        mov     edi,fasm_parameters
31 halyavin 328
 
122 diamond 329
        cmp     byte[esi],'/'
330
        je      .yes_systree
31 halyavin 331
 
122 diamond 332
        mov     ecx,[f_info.length] ; [s_fname.size]
333
        rep     movsb
31 halyavin 334
 
122 diamond 335
        mov     al,','
336
        stosb
31 halyavin 337
 
122 diamond 338
        mov     ecx,[f_info.length] ; [s_fname.size]
339
        add     ecx,-4
340
        mov     esi,f_info.path ; s_fname
341
        rep     movsb
31 halyavin 342
 
122 diamond 343
        mov     al,','
344
        stosb
31 halyavin 345
 
122 diamond 346
        mov     dword[edi],'/RD/'
347
        mov     word[edi+4],'1/'
348
        add     edi,6
31 halyavin 349
 
122 diamond 350
        mov     al,0
351
        stosb
31 halyavin 352
 
122 diamond 353
        jmp     .run
31 halyavin 354
 
355
 .yes_systree:
122 diamond 356
        mov     eax,[f_info.length]
357
        add     esi,eax ; [s_fname.size]
358
        dec     esi
31 halyavin 359
 
122 diamond 360
        xor     ecx,ecx
361
        mov     al,'/'
362
    @@: cmp     [esi],al
363
        je      @f
364
        dec     esi
365
        inc     ecx
366
        jmp     @b
367
    @@: inc     esi
31 halyavin 368
 
122 diamond 369
        push    esi esi ecx
31 halyavin 370
 
122 diamond 371
        rep     movsb
31 halyavin 372
 
122 diamond 373
        mov     al,','
374
        stosb
31 halyavin 375
 
122 diamond 376
        pop     ecx esi
31 halyavin 377
 
122 diamond 378
        add     ecx,-4
379
        rep     movsb
31 halyavin 380
 
122 diamond 381
        mov     al,','
382
        stosb
31 halyavin 383
 
122 diamond 384
        pop     ecx
385
        sub     ecx,f_info.path ; s_fname
386
        mov     esi,f_info.path ; s_fname
31 halyavin 387
 
122 diamond 388
        rep     movsb
31 halyavin 389
 
122 diamond 390
        mov     al,0
391
        stosb
31 halyavin 392
 
393
 .run:
122 diamond 394
        cmp     bl,0 ; run outfile ?
395
        je      @f
396
        mov     dword[edi-1],',run'
397
        mov     byte[edi+3],0
178 heavyiron 398
    @@:
399
        mov     ebx, fasm_start
400
start_ret:
401
        mov     eax, 70
402
        int     0x40
122 diamond 403
        ret
31 halyavin 404
endf
405
 
122 diamond 406
;-----------------------------------------------------------------------------
407
func open_debug_board ;///////////////////////////////////////////////////////
408
;-----------------------------------------------------------------------------
178 heavyiron 409
        mov     ebx, board_start
410
        jmp     start_ret
31 halyavin 411
endf
412
 
122 diamond 413
;-----------------------------------------------------------------------------
414
func open_sysfuncs_txt ;//////////////////////////////////////////////////////
415
;-----------------------------------------------------------------------------
178 heavyiron 416
        mov     ebx, docpak_start
417
        call    start_ret
122 diamond 418
        cmp     eax,0xfffffff0
419
        jb      @f
178 heavyiron 420
        mov     ebx, tinypad_start
421
        mov     dword [ebx+8], sysfuncs_filename
422
        call    start_ret
122 diamond 423
    @@: ret
31 halyavin 424
endf
425
 
122 diamond 426
;-----------------------------------------------------------------------------
178 heavyiron 427
;func layout  ;///// change keyboard layout ///////////////////////////////////
122 diamond 428
;-----------------------------------------------------------------------------
178 heavyiron 429
;        mcall   19,setup,param_setup
430
;        mcall   5,eax
431
;;       call    activate_me
432
;;       ret
433
;;endf
434
 
435
;;func activate_me
436
;        mcall   9,p_info,-1
437
;        inc     eax
438
;        inc     eax
439
;        mov     ecx,eax
440
;        mov     edi,[p_info.PID]
441
;        mov     ebx,p_info
442
;    @@: dec     ecx
443
;        jz      @f    ; counter=0 => not found? => return
444
;        mcall   9
445
;        cmp     edi,[p_info.PID]
446
;        jne     @b
447
;        mcall   18,3
448
;        mcall   5,eax
449
;    @@: ret
31 halyavin 450
;endf
451
 
122 diamond 452
func set_opt
453
        test    [options],al
454
        je      @f
455
        not     al
456
        and     [options],al
457
        ret
458
    @@: or      [options],al
459
        ret
31 halyavin 460
endf
461
 
122 diamond 462
func set_line_numbers
463
        mov     al,OPTS_LINENUMS
464
        call    set_opt
465
        ret
31 halyavin 466
endf
467
 
122 diamond 468
func set_optimal_fill
469
        mov     al,OPTS_OPTIMSAVE
470
        call    set_opt
471
        ret
31 halyavin 472
endf
473
 
122 diamond 474
func set_auto_indents
475
        mov     al,OPTS_AUTOINDENT
476
        call    set_opt
477
        ret
31 halyavin 478
endf
479
 
122 diamond 480
func set_auto_braces
481
        mov     al,OPTS_AUTOBRACES
482
        call    set_opt
483
        ret
31 halyavin 484
endf
485
 
122 diamond 486
func set_secure_sel
487
        mov     al,OPTS_SECURESEL
488
        call    set_opt
489
        ret
31 halyavin 490
endf
491
 
122 diamond 492
;-----------------------------------------------------------------------------
31 halyavin 493
 
122 diamond 494
include 'tp-draw.asm'
495
include 'tp-key.asm'
496
include 'tp-butto.asm'
497
include 'tp-mouse.asm'
498
include 'tp-files.asm'
499
include 'tp-commo.asm'
500
include 'tp-dialo.asm'
501
include 'tp-popup.asm'
502
include 'tp-tbox.asm'
31 halyavin 503
 
178 heavyiron 504
;include 'lib-ini.asm'
505
 
31 halyavin 506
;-----------------------------------------------------------------------------
122 diamond 507
section @DATA ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 508
;-----------------------------------------------------------------------------
509
 
122 diamond 510
;addr       dd s_fname  ; address of input string
511
;temp       dd 0xABCD   ; used in read_string
512
vscrl_capt dd -1
513
hscrl_capt dd -1
514
body_capt  dd -1
31 halyavin 515
 
122 diamond 516
key0 db \
517
  0x00,0x00,0x02,0x03,0x04,0x05,0x06,0x07,\
518
  0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x00,0x00,\
519
  0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,\
520
  0x18,0x19,0x1A,0x1B,0x00,0x00,0x1E,0x1F,\
521
  0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,\
522
  0x28,0x29,0x00,0x2B,0x2C,0x2D,0x2E,0x2F,\
523
  0x30,0x31,0x32,0x33,0x34,0x35,0x00,0x00,\
524
  0x00,0x39,0x00,0x00,0x00,0x00,0x00,0x00
525
  times 12*16 db 0x00
31 halyavin 526
 
122 diamond 527
accel_table dd                      \
528
  0x0000000E,key.bkspace           ,\ ; BackSpace
529
  0x0000000F,key.tab               ,\ ; Tab
530
  0x0000001C,key.return            ,\ ; Return
531
  0x0000003D,key.f3                ,\ ; F3
532
  0x00000043,key.f9                ,\ ; F9
533
  0x00000147,key.home              ,\ ; Home
534
  0x00000148,key.up                ,\ ; Up
535
  0x00000149,key.pgup              ,\ ; PageUp
536
  0x0000014B,key.left              ,\ ; Left
537
  0x0000014D,key.right             ,\ ; Right
538
  0x0000014F,key.end               ,\ ; End
539
  0x00000150,key.down              ,\ ; Down
540
  0x00000151,key.pgdn              ,\ ; PageDown
541
  0x00000152,key.ins               ,\ ; Insert
542
  0x00000153,key.del               ,\ ; Delete
543
  0x00010147,key.shift_home        ,\ ; Shift+Home
544
  0x00010148,key.shift_up          ,\ ; Shift+Up
545
  0x00010149,key.shift_pgup        ,\ ; Shift+PageUp
546
  0x0001014B,key.shift_left        ,\ ; Shift+Left
547
  0x0001014D,key.shift_right       ,\ ; Shift+Right
548
  0x0001014F,key.shift_end         ,\ ; Shift+End
549
  0x00010150,key.shift_down        ,\ ; Shift+Down
550
  0x00010151,key.shift_pgdn        ,\ ; Shift+PageDown
551
  0x00010153,key.del               ,\ ; Shift+Delete
552
  0x00020015,key.ctrl_y            ,\ ; Ctrl+Y
553
  0x00020018,key.ctrl_o            ,\ ; Ctrl+O
554
  0x0002001E,key.ctrl_a            ,\ ; Ctrl+A
555
  0x0002001F,key.ctrl_s            ,\ ; Ctrl+S
556
  0x00020020,key.ctrl_d            ,\ ; Ctrl+D
557
  0x00020021,key.ctrl_f            ,\ ; Ctrl+F
558
  0x00020022,key.ctrl_g            ,\ ; Ctrl+G
559
  0x00020023,key.ctrl_h            ,\ ; Ctrl+H
560
\;0x00020026,key.ctrl_l            ,\ ; Ctrl+L
561
  0x0002002D,key.ctrl_x            ,\ ; Ctrl+X
562
  0x0002002E,key.ctrl_c            ,\ ; Ctrl+C
563
  0x0002002F,key.ctrl_v            ,\ ; Ctrl+V
564
  0x00020031,key.ctrl_n            ,\ ; Ctrl+N
565
  0x00020043,key.ctrl_f9           ,\ ; Ctrl+F9
566
  0x00020147,key.ctrl_home         ,\ ; Ctrl+Home
567
\;0x00020148,key.ctrl_up           ,\ ; Ctrl+Up
568
  0x00020149,key.ctrl_pgup         ,\ ; Ctrl+PageUp
569
  0x0002014B,key.ctrl_left         ,\ ; Ctrl+Left
570
  0x0002014D,key.ctrl_right        ,\ ; Ctrl+Right
571
  0x0002014F,key.ctrl_end          ,\ ; Ctrl+End
572
\;0x00020150,key.ctrl_down         ,\ ; Ctrl+Down
573
  0x00020151,key.ctrl_pgdn         ,\ ; Ctrl+PageDown
574
  0x00020153,key.del               ,\ ; Ctrl+Del
575
  0x0003001F,key.shift_ctrl_s      ,\ ; Shift+Ctrl+S
576
  0x00030147,key.shift_ctrl_home   ,\ ; Shift+Ctrl+Home
577
\;0x00030148,key.shift_ctrl_up     ,\ ; Shift+Ctrl+Up
578
  0x00030149,key.shift_ctrl_pgup   ,\ ; Shift+Ctrl+PageUp
579
  0x0003014B,key.shift_ctrl_left   ,\ ; Shift+Ctrl+Left
580
  0x0003014D,key.shift_ctrl_right  ,\ ; Shift+Ctrl+Right
581
  0x0003014F,key.shift_ctrl_end    ,\ ; Shift+Ctrl+End
582
\;0x00030150,key.shift_ctrl_down   ,\ ; Shift+Ctrl+Down
583
  0x00030151,key.shift_ctrl_pgdn   ,\ ; Shift+Ctrl+PageDown
584
  0x0004002D,key.alt_x             ,\ ; Alt+X
585
 
31 halyavin 586
 
122 diamond 587
accel_table_textbox dd              \
588
\;0x00000001,key.tb.escape         ,\ ; Escape
589
  0x0000000E,key.tb.bkspace        ,\ ; BackSpace
590
\;0x0000000F,key.tb.tab            ,\ ; Tab
591
\;0x0000001C,key.tb.return         ,\ ; Return
592
  0x00000147,key.tb.home           ,\ ; Home
593
  0x0000014B,key.tb.left           ,\ ; Left
594
  0x0000014D,key.tb.right          ,\ ; Right
595
  0x0000014F,key.tb.end            ,\ ; End
596
  0x00000153,key.tb.del            ,\ ; Delete
597
  0x00010147,key.tb.shift_home     ,\ ; Shift+Home
598
  0x0001014B,key.tb.shift_left     ,\ ; Shift+Left
599
  0x0001014D,key.tb.shift_right    ,\ ; Shift+Right
600
  0x0001014F,key.tb.shift_end      ,\ ; Shift+End
601
  0x00010153,key.tb.del            ,\ ; Shift+Del
602
 
31 halyavin 603
 
122 diamond 604
accel_table2 dd            \
605
  1,btn.close_main_window ,\
606
\;10000,btn.compile       ,\
607
\;10001,btn.compile_run   ,\
608
\;10002,btn.debug_board   ,\
609
\;10003,btn.sysfuncs_txt  ,\
610
  'UP',btn.scroll_up      ,\
611
  'DN',btn.scroll_down    ,\
612
  'LT',btn.scroll_left    ,\
613
  'RT',btn.scroll_right   ,\
614
\;5,key.ctrl_o            ,\
615
 
31 halyavin 616
 
122 diamond 617
accel_table2_botdlg dd     \
618
  1,btn.close_main_window ,\
619
  20001,btn.bot.cancel    ,\
620
  20002,btn.bot.opensave  ,\
621
  20003,btn.bot.find      ,\
622
 
31 halyavin 623
 
624
add_table:
625
; times $61 db -$00
626
  times $1A db -$20
627
  times $25 db -$00
628
  times $10 db -$20
629
  times $30 db -$00
630
  times $10 db -$50
631
  times $04 db -$00,-$01
632
  times $08 db -$00
633
 
122 diamond 634
;error_beep      db 0xA0,0x30,0
31 halyavin 635
 
178 heavyiron 636
s_status dd 0
637
 
122 diamond 638
sz s_example,'EXAMPLE.ASM'
31 halyavin 639
sz s_still  ,'still'
640
 
122 diamond 641
;sz param_setup,'LANG',0 ; parameter for SETUP
31 halyavin 642
 
178 heavyiron 643
fasm_start:
644
        dd      7
645
        dd      0
646
        dd      fasm_parameters
647
        dd      0
648
        dd      0
649
        db      '/RD/1/FASM',0
650
board_start:
651
        dd      7
652
        dd      0
653
        dd      0
654
        dd      0
655
        dd      0
656
        db      '/RD/1/BOARD',0
657
tinypad_start:
658
        dd      7
659
        dd      0
660
        dd      ?
661
        dd      0
662
        dd      0
663
        db      '/RD/1/TINYPAD',0
664
docpak_start:
665
        dd      7
666
        dd      0
667
        dd      sysfuncs_param
668
        dd      0
669
        dd      0
670
        db      '/RD/1/DOCPAK',0
671
 
122 diamond 672
;sz setup           ,'SETUP      ' ; to change keyboard layout
31 halyavin 673
 
122 diamond 674
sz sysfuncs_param,'g',0
675
 
31 halyavin 676
lsz sysfuncs_filename,\
677
  ru,<'SYSFUNCR.TXT',0>,\
678
  en,<'SYSFUNCS.TXT',0>
679
 
178 heavyiron 680
sz htext,'TINYPAD 4.0.3'
31 halyavin 681
 
682
lszc help_text,b,\
683
  ru,'КОМАНДЫ:',\
684
  ru,' ',\
685
  ru,'  CTRL+F1 : Это окно',\
686
  ru,'  CTRL+S  : Первая строка для копирования',\
687
  ru,'  CTRL+E  : Последняя строка для копирования',\
688
  ru,'  CTRL+P  : Вставить выбранное на текущую позицию',\
689
  ru,'  CTRL+D  : Удалить строку',\
690
  ru,'  CTRL+L  : Вставить строку-разделитель',\
691
  ru,'  CTRL+[  : Перейти в начало файла',\
692
  ru,'  CTRL+]  : Перейти в конец файла',\
693
  ru,'  CTRL+F2 : Загрузить файл',\
694
  ru,'  CTRL+F3 : Поиск',\
695
  ru,'  CTRL+F4 : Сохранить файл',\
696
  ru,'  CTRL+F5 : Ввести имя файла',\
697
  ru,'  CTRL+F6 : Ввести строку для поиска',\
698
  ru,'  CTRL+F8 : Сменить раскладку клавиатуры',\
122 diamond 699
\
31 halyavin 700
  en,'COMMANDS:',\
701
  en,' ',\
702
  en,'  CTRL+F1 : SHOW THIS WINDOW',\
703
  en,'  CTRL+S  : SELECT FIRST STRING TO COPY',\
704
  en,'  CTRL+E  : SELECT LAST STRING TO COPY',\
705
  en,'  CTRL+P  : PASTE SELECTED TO CURRENT POSITION',\
706
  en,'  CTRL+D  : DELETE CURRENT LINE',\
707
  en,'  CTRL+L  : INSERT SEPARATOR LINE',\
708
  en,'  CTRL+[  : GO TO THE BEGINNING OF FILE',\
709
  en,'  CTRL+]  : GO TO THE END OF FILE',\
710
  en,'  CTRL+F2 : LOAD FILE',\
711
  en,'  CTRL+F3 : SEARCH',\
712
  en,'  CTRL+F4 : SAVE FILE',\
713
  en,'  CTRL+F5 : ENTER FILENAME',\
714
  en,'  CTRL+F6 : ENTER SEARCH STRING',\
122 diamond 715
  en,'  CTRL+F8 : CHANGE KEYBOARD LAYOUT'
716
db 0
31 halyavin 717
 
122 diamond 718
menubar_res main_menu,\
719
  ru,'Файл'  ,popup_file   ,onshow.file   ,\
720
  ru,'Правка',popup_edit   ,onshow.edit   ,\
721
  ru,'Поиск' ,popup_search ,onshow.search ,\
722
  ru,'Запуск',popup_run    ,onshow.run    ,\
723
  ru,'Опции' ,popup_options,onshow.options,\
724
\
725
  en,'File'   ,popup_file   ,onshow.file  ,\
726
  en,'Edit'   ,popup_edit   ,onshow.edit  ,\
727
  en,'Search' ,popup_search ,onshow.search,\
728
  en,'Run'    ,popup_run    ,onshow.run   ,\
729
  en,'Options',popup_options,onshow.options
31 halyavin 730
 
122 diamond 731
popup_res popup_file,\
178 heavyiron 732
  ru,'Новый'           ,'Ctrl+N'      ,key.ctrl_n      ,\
733
  ru,'Открыть...'      ,'Ctrl+O'      ,key.ctrl_o      ,\
734
  ru,'Сохранить'       ,'Ctrl+S'      ,key.ctrl_s      ,\
735
  ru,'Сохранить как...','Ctrl+Shift+S',key.shift_ctrl_s,\
736
  ru,'-'               ,''            ,0               ,\
737
  ru,'Выход'           ,'Alt+X'       ,key.alt_x       ,\
122 diamond 738
\
178 heavyiron 739
  en,'New'       ,'Ctrl+N'      ,key.ctrl_n      ,\
740
  en,'Open...'   ,'Ctrl+O'      ,key.ctrl_o      ,\
741
  en,'Save'      ,'Ctrl+S'      ,key.ctrl_s      ,\
742
  en,'Save as...','Ctrl+Shift+S',key.shift_ctrl_s,\
743
  en,'-'         ,''            ,0               ,\
744
  en,'Exit'      ,'Alt+X'       ,key.alt_x
31 halyavin 745
 
122 diamond 746
popup_res popup_edit,\
747
  ru,'Вырезать'    ,'Ctrl+X',key.ctrl_x,\
748
  ru,'Копировать'  ,'Ctrl+C',key.ctrl_c,\
749
  ru,'Вставить'    ,'Ctrl+V',key.ctrl_v,\
750
  ru,'Удалить'     ,''      ,key.del   ,\
751
  ru,'-'           ,''      ,0         ,\
752
  ru,'Выделить всё','Ctrl+A',key.ctrl_a,\
178 heavyiron 753
\;  ru,'-'           ,''      ,0         ,\
754
\;  ru,'Вертикальное выделение','Alt+Ins',0         ,\
122 diamond 755
\
756
  en,'Cut'       ,'Ctrl+X',key.ctrl_x,\
757
  en,'Copy'      ,'Ctrl+C',key.ctrl_c,\
758
  en,'Paste'     ,'Ctrl+V',key.ctrl_v,\
759
  en,'Delete'    ,''      ,key.del   ,\
760
  en,'-'         ,''      ,0         ,\
178 heavyiron 761
  en,'Select all','Ctrl+A',key.ctrl_a;,\
762
;  en,'-'         ,''      ,0         ,\
763
;  en,'Vertical selection','Alt+Ins',0
31 halyavin 764
 
122 diamond 765
popup_res popup_search,\
766
  ru,'Перейти...' ,'Ctrl+G',key.ctrl_g,\
767
  ru,'-'          ,''      ,0         ,\
768
  ru,'Найти...'   ,'Ctrl+F',key.ctrl_f,\
769
  ru,'Найти далее','F3'    ,key.f3    ,\
770
  ru,'Заменить...','Ctrl+H',key.ctrl_h,\
771
\
772
  en,'Position...','Ctrl+G',key.ctrl_g,\
773
  en,'-'          ,''      ,0         ,\
774
  en,'Find...'    ,'Ctrl+F',key.ctrl_f,\
775
  en,'Find next'  ,'F3'    ,key.f3    ,\
776
  en,'Replace...' ,'Ctrl+H',key.ctrl_h
31 halyavin 777
 
122 diamond 778
popup_res popup_run,\
779
  ru,'Запустить'        ,'F9'     ,key.f9           ,\
780
  ru,'Компилировать'    ,'Ctrl+F9',key.ctrl_f9      ,\
781
  ru,'-'                ,''       ,0                ,\
782
  ru,'Доска отладки'    ,''       ,open_debug_board ,\
783
  ru,'Системные функции',''       ,open_sysfuncs_txt,\
784
\
785
  en,'Run'              ,'F9'     ,key.f9           ,\
786
  en,'Compile'          ,'Ctrl+F9',key.ctrl_f9      ,\
787
  en,'-'                ,''       ,0                ,\
788
  en,'Debug board'      ,''       ,open_debug_board ,\
789
  en,'System functions' ,''       ,open_sysfuncs_txt
790
 
791
popup_res popup_options,\
792
  ru,'Внешний вид...'        ,'',0,\
793
  ru,'-'                     ,'',0,\
794
  ru,'Безопасное выделение'  ,'',set_secure_sel,\
795
  ru,'Автоматические скобки' ,'',set_auto_braces,\
796
  ru,'Автоматический отступ' ,'',set_auto_indents,\
797
  ru,'Умная табуляция'       ,'',0,\
798
  ru,'Оптимальное сохранение','',set_optimal_fill,\
799
  ru,'-'                     ,'',0,\
800
  ru,'Номера строк'          ,'',set_line_numbers,\
801
\
802
  en,'Appearance...'         ,'',0,\
803
  en,'-'                     ,'',0,\
804
  en,'Secure selection'      ,'',set_secure_sel,\
805
  en,'Automatic brackets'    ,'',set_auto_braces,\
806
  en,'Automatic indents'     ,'',set_auto_indents,\
807
  en,'Smart tabulation'      ,'',0,\
808
  en,'Optimal fill on saving','',set_optimal_fill,\
809
  en,'-'                     ,'',0,\
810
  en,'Line numbers'          ,'',set_line_numbers
811
 
812
lsz s_modified,\
813
  ru,'Изменено',\
814
  en,'Modified'
815
 
816
lsz s_2filename,\
817
  ru,'Имя файла:',\
818
  en,'Filename:'
819
lsz s_2open,\
820
  ru,'Открыть',\
821
  en,'Open'
822
lsz s_2save,\
823
  ru,'Сохранить',\
824
  en,'Save'
825
lsz s_2find,\
826
  ru,'Найти',\
827
  en,'Find'
828
db ':'
829
lsz s_2replace,\
830
  ru,'Заменить',\
831
  en,'Replace'
832
db ':'
833
lsz s_2cancel,\
834
  ru,'Отмена',\
835
  en,'Cancel'
836
 
178 heavyiron 837
lsz s_enter_filename,\
838
  ru,<'Введите имя файла',0>,\
839
  en,<'Enter filename',0>
840
 
841
lsz s_enter_text_to_find,\
842
  ru,<'Введите текст для поиска',0>,\
843
  en,<'Enter text to find',0>
844
 
845
lsz s_enter_text_to_replace,\
846
  ru,<'Введите текст для замены',0>,\
847
  en,<'Enter text to replace',0>
848
 
849
lsz s_text_not_found,\
850
  ru,<'Достигнут конец файла, текст не найден',0>,\
851
  en,<'Reached end of file, text not found',0>
852
 
853
lszc s_fs_error,b,\
854
  ru,<'Операция завершена успешно (0)',0>,\
855
  ru,<'',0>,\
856
  ru,<'Функция не поддерживается для данной файловой системы (2)',0>,\
857
  ru,<'Неизвестная файловая система (3)',0>,\
858
  ru,<'',0>,\
859
  ru,<'Невозможно открыть файл (5)',0>,\
860
  ru,<'Операция завершена успешно (6)',0>,\
861
  ru,<'Адрес находится за границами памяти программы (7)',0>,\
862
  ru,<'На диске нет свободного места (8)',0>,\
863
  ru,<'Таблица FAT уничтожена (9)',0>,\
864
  ru,<'Доступ запрещён (10)',0>,\
865
  ru,<'Ошибка устройства (11)',0>,\
866
\
867
  en,<'Operation executed successfully (0)',0>,\
868
  en,<'',0>,\
869
  en,<'Function is not supported for the given filesystem (2)',0>,\
870
  en,<'Unknown filesystem (3)',0>,\
871
  en,<'',0>,\
872
  en,<'Unable to open file (5)',0>,\
873
  en,<'Operation executed successfully (6)',0>,\
874
  en,<'Pointer lies outside of application memory (7)',0>,\
875
  en,<'Disk is full (8)',0>,\
876
  en,<'FAT table is destroyed (9)',0>,\
877
  en,<'Access denied (10)',0>,\
878
  en,<'Device error (11)',0>
879
 
122 diamond 880
sz symbols_ex,';?.%"',"'"
881
sz symbols   ,'#&*\:/<>|{}()[]=+-, '
882
 
178 heavyiron 883
ini_sec_window    db 'Window',0
884
ini_window_top    db 'Top',0
885
ini_window_left   db 'Left',0
886
ini_window_right  db 'Right',0
887
ini_window_bottom db 'Bottom',0
888
 
889
finfo_ini dd ?,?,?,AREA_TEMP,AREA_EDIT-AREA_TEMP
890
          db '/rd/1/tinypad.ini',0
891
 
122 diamond 892
TINYPAD_END:     ; end of file
893
 
894
self_path rb PATHL
895
 
31 halyavin 896
;-----------------------------------------------------------------------------
122 diamond 897
section @UDATA ;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 898
;-----------------------------------------------------------------------------
899
 
178 heavyiron 900
f_info70 rd 7
901
 
122 diamond 902
f_info.length dd ?
903
f_info dd ?,?,?,?,?;?,0,?,AREA_TEMP,AREA_EDIT-AREA_TEMP
904
 
905
f_info.path:
906
    times PATHL+1 db ?
907
 
908
pos.x         dd ?    ; global X position (cursor)
909
pos.y         dd ?    ; global Y position (cursor)
910
sel.x         dd ?    ; global X position (selection start)
911
sel.y         dd ?    ; global Y position (selection start)
912
lines         dd ?    ; number of lines in file
913
lines.scr     dd ?    ; number of lines on the screen
31 halyavin 914
columns       dd ?    ; number of columns in file
122 diamond 915
columns.scr   dd ?    ; number of columns on the screen
31 halyavin 916
top_ofs       dd ?    ; height occupied by top buttons
917
bot_ofs       dd ?    ; height occupied by bottom buttons
122 diamond 918
              dw ?
919
left_ofs      dd ?    ;
31 halyavin 920
top_line      dd ?    ; topmost visible line on screen
921
left_col      dd ?    ; leftmost visible char on line
922
vscrl_top     dd ?
923
vscrl_size    dd ?
924
hscrl_top     dd ?
925
hscrl_size    dd ?
178 heavyiron 926
;skinh         dd ?    ; skin height
122 diamond 927
__rc          dd ?,?,?,?
31 halyavin 928
;filelen       dd ?    ; file size (on save) ???
929
filesize      dd ?    ; file size (on load) ???
122 diamond 930
ya            dd ?    ; for read_string
931
;copy_start    dd ?    ; first line for copying (Ctrl+S)
31 halyavin 932
copy_count    dd ?    ; number of lines for copying (Ctrl+E)
933
copy_size     dd ?    ; size of data to copy
934
s_title.size  dd ?    ; caption length
935
 
122 diamond 936
draw_blines   dd ?    ; last line to draw
937
 
31 halyavin 938
cur_line_len  dd ?
122 diamond 939
h_popup       dd ?
940
bot_dlg_handler dd ?
31 halyavin 941
 
122 diamond 942
sel.begin.x   dd ?
943
sel.begin.y   dd ?
944
sel.end.x     dd ?
945
sel.end.y     dd ?
946
sel.selected  db ?
947
 
948
in_sel        db ?
949
 
31 halyavin 950
asm_mode      db ?    ; ASM highlight?
951
do_not_draw   db ?    ; draw top and bottom buttons?
122 diamond 952
main_closed   db ?    ; main window closed?
953
tb_casesen    db ?    ; focused textbox is case-sensitive?
31 halyavin 954
 
955
align 4
956
s_fname.size  dd ?
957
s_fname       rb PATHL+1
958
align 4
959
s_search.size dd ?
960
s_search      rb PATHL+1
961
 
122 diamond 962
s_title       rb PATHL+11  ; window caption
31 halyavin 963
 
122 diamond 964
chr db ?
965
ext db ?
966
shi dd ?
967
 
968
align 4
969
cl_3d_normal dd ?
970
cl_3d_pushed dd ?
971
cl_3d_outset dd ?
972
cl_3d_inset  dd ?
973
cl_3d_grayed dd ?
974
 
975
tb_opensave  TBOX
976
tb_find      TBOX
977
tb_replace   TBOX
978
tb_gotorow   TBOX
979
tb_gotocol   TBOX
980
 
981
focused_tb   dd ?
982
 
983
key1 rb 256
984
 
985
mst  db ?
986
mst2 db ?
987
mev  db ?
988
mouse_captured  db ?
989
just_from_popup db ?
990
 
991
bot_mode db ?
992
 
993
modified db ?
994
 
995
align 4
996
 
997
bot_dlg_height dd ?
998
bot_dlg_mode2  db ?
999
 
31 halyavin 1000
;-----------------------------------------------------------------------------
122 diamond 1001
section @PARAMS ;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
31 halyavin 1002
;-----------------------------------------------------------------------------
1003
 
1004
fasm_parameters:
1005
 
122 diamond 1006
p_info  process_information
1007
p_info2 process_information
1008
sc      system_colors
1009
 
1010
diff16 'Main memory size',0,$
1011
 
1012
MAIN_STACK  = 0x0000FFF0
1013
POPUP_STACK = 0x0000EFF0
1014
 
1015
AREA_TEMP   = 0x00010000 ; 0x00010000
1016
AREA_EDIT   = 0x000C0000 ; 0x00080000
1017
AREA_TEMP2  = 0x00190000 ; 0x002E0000
1018
AREA_CBUF   = 0x001A0000 ; 0x002F0000
1019
AREA_ENDMEM = 0x001B0000 ; 0x00300000
1020
 
1021
diff10 'Header+options size',0,@CODE
1022
diff10 'Load area size',AREA_TEMP,AREA_EDIT
1023
diff10 'Edit area size',AREA_EDIT,AREA_TEMP2
1024
diff10 'Total memory usage',0,AREA_ENDMEM
1025
 
1026
;store dword '/hd/' at tb_opensave.text+4*0
1027
;store dword '1/tp' at tb_opensave.text+4*1
1028
;store dword 'ad4/' at tb_opensave.text+4*2
1029
;store dword 'tiny' at tb_opensave.text+4*3
1030
;store dword 'pad.' at tb_opensave.text+4*4
1031
;store dword 'asm'  at tb_opensave.text+4*5
1032
;store byte  23     at tb_opensave.length