Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
6582 nisargshah 1
@use_library_mem mem.Alloc, mem.Free, mem.ReAlloc, dll.Load
2
 
7167 nisargshah 3
icon_tl_sys dd 0
4
icon_tl_nod dd 0
6582 nisargshah 5
 
6
TLIST_SZ = 325+16 ;=341. 16 is x-size of scroll bar
7
TLIST1_X = 50
8
TLIST2_X = 409
9
BT_SZ_X  = 40
10
SYS_COL  = 0xe6e6e6
11
BT_COL   = 0xcccccc
12
STR_COL  = 0x595959 ;0x000000
13
 
14
; TODO: automatic resizing of GUI elements on window resizing
15
 
16
align 4
17
;;================================================================================================;;
18
gui: ;////////////////////////////////////////////////////////////////////////////////////////////;;
19
;;------------------------------------------------------------------------------------------------;;
20
;? GUI-specific functions                                                                         ;;
21
;;------------------------------------------------------------------------------------------------;;
22
;> none                                                                                           ;;
23
;;------------------------------------------------------------------------------------------------;;
24
;< none                                                                                           ;;
25
;;================================================================================================;;
26
 
27
    dd .init
28
    dd .server_addr
29
    dd .get_username
30
    dd .get_cmd
31
    dd .print
32
    dd .set_flags
33
    dd .list
34
    dd .progress
35
    dd .error
36
 
37
    .init:
38
        ; load libraries
7167 nisargshah 39
        stdcall dll.Load, @IMPORT_GUI_LIBS
6582 nisargshah 40
        test    eax, eax
41
        jnz     .exit
42
 
43
        mcall   48, 3, sc, sizeof.system_colors
44
        mcall   40, 0xC0000027 ; set event mask
45
        ret
46
 
47
    .server_addr:
48
        mov     [auto_list], 1
49
        jmp     login_gui.server_addr
50
 
51
    .get_username:
52
        jmp     login_gui.get_username
53
 
54
 
55
;;================================================================================================;;
56
    .main: ;//////////////////////////////////////////////////////////////////////////////////////;;
57
;;------------------------------------------------------------------------------------------------;;
58
;? Initialize tree list, editbox and textedit elements                                            ;;
59
;;------------------------------------------------------------------------------------------------;;
60
;> none                                                                                           ;;
61
;;------------------------------------------------------------------------------------------------;;
62
;< none                                                                                           ;;
63
;;================================================================================================;;
64
 
65
        stdcall [ted_init], tedit0
66
        mov     dword[tedit0.rec.width], 9
67
        mov     dword[tedit0.rec.height], 16
68
 
69
        stdcall dword[edit_box_set_text], edit_volume, root_dir
70
 
71
        ; initialize tree list elements
72
        stdcall dword[tl_data_init], tree1
73
        stdcall dword[tl_data_init], tree2
74
 
7167 nisargshah 75
        ; read icons
76
        load_image_file 'tl_sys_16.png', icon_tl_sys
77
 
6582 nisargshah 78
        mov     [filestruct.ptr], eax
79
        mov     [filestruct.subfn], 0
80
        mov     [filestruct.offset], 54
81
        mov     [filestruct.size], ecx
82
        mcall   70, filestruct
83
        cmp     ebx, 0
84
        jl      @f
7167 nisargshah 85
        m2m     dword[tree1.data_img_sys], dword[icon_tl_sys]
86
        m2m     dword[tree2.data_img_sys], dword[icon_tl_sys]
6582 nisargshah 87
 
88
      @@:
7167 nisargshah 89
        ; read nodes icon file
90
        load_image_file 'tl_nod_16.png', icon_tl_nod
91
 
6582 nisargshah 92
        mov     [filestruct.ptr], eax
93
        ;mov    [filestruct.subfn], 0
94
        ;mov    [filestruct.offset], 54
95
        mov     [filestruct.size], ecx
96
        mcall   70, filestruct
97
        cmp     ebx, 0
98
        jl      @f
7167 nisargshah 99
        m2m     dword[tree1.data_img], dword[icon_tl_nod]
100
        m2m     dword[tree2.data_img], dword[icon_tl_nod]
6582 nisargshah 101
 
102
      @@:
103
        mcall   67, 35, 20, 830, 555 ; resize to main gui window's coordinates
104
        call    .draw
105
        ; create initial tree list for root_dir
106
        call    populate_local_tree_list
107
        jmp     arg_handler.connect
108
 
109
    .get_cmd:
110
        dec     [auto_list]
111
        jnz     .redraw
112
        call    .clear_remote_tree
113
        jmp     cmd_list
114
 
115
    .redraw:
116
        call     .draw
117
 
118
    align 4
119
    .still:
120
        mcall   10
121
 
122
        dec     eax
123
        jz      .redraw
124
        dec     eax
125
        jz      .key
126
        dec     eax
127
        jz      .button
128
        sub     eax, 3
129
        jz      .mouse
130
 
131
        jmp     .still
132
 
133
    .error:
134
        jmp     login_gui.error
135
 
136
    .exit:
137
    ;   stdcall mem.Free,[bmp_icon]
138
        stdcall dword[tl_data_clear], tree1
139
        stdcall dword[tl_data_clear], tree2
140
        stdcall [ted_delete], tedit0
141
        jmp     exit
142
 
143
    align 4
144
    .draw:
145
        mcall   12, 1
146
        ; main window
147
        mcall   0, <35,830>, <20,555>, 0x34000000+SYS_COL, 0x805080DD, hed
148
 
149
        ;-------------------------
150
        ; textedit components
151
        ;-------------------------
152
        mcall   9, procinfo, -1
153
        mov     edi, tedit0
154
        call    EvSize
155
 
156
        movzx   ebx,word[procinfo.client_box.width]
157
        inc     bx
158
        mcall   13, , ted_wnd_t
159
        stdcall [ted_draw], tedit0
160
 
161
        ; draw "disconnect" button
162
        mcall   8, <50,85>, <25,25>, 3, BT_COL
163
        ; string "disconnect"
164
        mcall   4, <50+5,25+5>, 0xb0000000+STR_COL, str_disconnect
165
        ; draw "Copy" button
166
        mcall   8, <50,40>, <326,25>, 4, BT_COL
167
        ; string "copy"
168
        mcall   4, <50+5,326+5>, 0xb0000000+STR_COL, str_copy
169
        ; draw "Search" button
170
        mcall   8, , <20,25>, 5, BT_COL
171
        ; string "Search"
172
        mcall   4, , 0xb0000000+STR_COL, str_search
173
 
174
        ; draw "LIST" button
175
        mcall   8, , <50,25>, 12, BT_COL
176
        ; string "LIST"
177
        mcall   4, , 0xb0000000+STR_COL, str_list
178
        ; draw "DELE" button
179
        mcall   8, , <50,25>, 7, BT_COL
180
        ; string "DELE"
181
        mcall   4, , 0xb0000000+STR_COL, str_dele
182
        ; draw "RDIR" button
183
        mcall   8, , <50,25>, 8, BT_COL
184
        ; string "RDIR"
185
        mcall   4, , 0xb0000000+STR_COL, str_rdir
186
        ; draw "RMD" button
187
        mcall   8, , <50,25>, 9, BT_COL
188
        ; string "RMD"
189
        mcall   4, , 0xb0000000+STR_COL, str_rmd
190
 
191
        ; draw "mkd" button
192
        mcall   8, , <80,20>, 6, BT_COL
193
        ; string "mkd"
194
        mcall   4, , 0xb0000000+STR_COL, str_mkd
195
 
196
        ; draw "cancel" button
197
        mcall   8, <555,55>, <308,25>, 10, BT_COL
198
        ; string "Cancel"
199
        mcall   4, <555+5,308+5>, 0xb0000000+STR_COL, str_abort
200
        ; draw "change volume" button
201
        mcall   8, , <100-20,22>, 11, BT_COL
202
        ; string "Change"
203
        mcall   4, , 0xb0000000+STR_COL, str_change
204
 
205
        ;--------------------------
206
        ; tree list components
207
        ;--------------------------
208
        stdcall dword[tl_draw], tree1
209
        stdcall dword[tl_draw], tree2
210
 
211
        mov     dword[wScr.all_redraw], 1
212
        stdcall [scrollbar_ver_draw], wScr
213
 
214
        mov     dword[wScr2.all_redraw],1
215
        stdcall [scrollbar_ver_draw], wScr2
216
 
217
        stdcall [edit_box_draw], edit_mkd
218
        stdcall [edit_box_draw], edit_volume
219
        stdcall [edit_box_draw], edit_search
220
 
221
        ; progress bar
222
        stdcall [progressbar_draw], pb
223
 
224
        mcall   12,2
225
        ret
226
 
227
    align 16
228
    .mouse:
229
        mcall   37, 1
230
        cmp     word[tedit0.wnd.top], ax
231
        jg      .no_edit
232
 
233
        shr     eax, 16
234
        cmp     word[tedit0.wnd.left], ax
235
        jg      .no_edit
236
 
237
        mcall   37, 3
238
        bt      eax, 24
239
        jnc     @f
240
 
241
        stdcall [ted_but_select_word], tedit0
242
        jmp     .still
243
 
244
      @@:
245
        stdcall [ted_mouse], tedit0
246
        jmp     .still
247
 
248
      .no_edit:
249
        stdcall [tl_mouse], tree1
250
        stdcall [tl_mouse], tree2
251
        stdcall [edit_box_mouse], edit_mkd
252
        stdcall [edit_box_mouse], edit_volume
253
        stdcall [edit_box_mouse], edit_search
254
        jmp     .still
255
 
256
    align 16
257
    .key:
258
        mcall   2
259
        stdcall [tl_key], tree1
260
        stdcall [tl_key], tree2
261
        stdcall [edit_box_key], edit_mkd
262
        stdcall [edit_box_key], edit_volume
263
        stdcall [edit_box_key], edit_search
264
        jmp     .still
265
 
266
    align 16
267
    .button:
268
        mcall   17
269
 
270
        cmp     ah, 3
271
        jne     @f
272
        ijmp    eax, interface_addr, interface.server_addr
273
        jmp     .still
274
 
275
      @@:
276
        cmp     ah, 4
277
        jne     @f
278
        stdcall [ted_but_copy], tedit0
279
        jmp     .still
280
 
281
      @@:
282
        cmp     ah, 5
283
        jne     @f
284
        je      filter_remote_list
285
 
286
      @@:
287
        cmp     ah, 6
288
        je      create_remote_dir
289
 
290
        cmp     ah, 7
291
        je      delete_file
292
 
293
        cmp     ah, 8
294
        je      cmd_rdir
295
 
296
        cmp     ah, 9
297
        je      remove_dir
298
 
299
        cmp     ah, 10
300
        je      cmd_abor
301
 
302
        cmp     ah, 11
303
        jne     @f
304
        call    populate_local_tree_list
305
 
306
      @@:
307
        cmp     ah, 12
308
        jne     @f
309
        call    .clear_remote_tree
310
        je      cmd_list
311
 
312
      @@:
313
        cmp     ah, 1
314
        je      .exit
315
 
316
        jmp     .still
317
 
318
    .print:
319
        pushad
320
        mov     ebx, ted_opt_ed_change_time + ted_opt_ed_move_cursor
321
        mov     ecx, 2 ; 0a0d
322
        mov     esi, [esp+36]
323
        mov     word[tedit_buffer], 0x0a0d
324
        lea     edi, [tedit_buffer+2]
325
 
326
      @@:
327
        movsb
328
        inc     ecx
329
        cmp     byte[esi], 0
330
        jne     @b
331
        stdcall [ted_text_add], tedit0, tedit_buffer, ecx, ebx
332
        stdcall [ted_draw], tedit0
333
        ; write to log file
334
        mov     eax, [esp+36]
7201 nisargshah 335
        sub     ecx, 2 ; 0a0d is not included
6582 nisargshah 336
        call    write_to_file
337
 
338
      @@:
339
        popad
340
        ret     4
341
 
342
    .set_flags:
343
        ret     4
344
 
345
 
346
;;================================================================================================;;
347
    .list: ;//////////////////////////////////////////////////////////////////////////////////////;;
348
;;------------------------------------------------------------------------------------------------;;
349
;? update tree2 with remote directory listing                                                     ;;
350
;;------------------------------------------------------------------------------------------------;;
351
;> buf_buffer2 = received data buffer                                                             ;;
352
;> eax = size of data                                                                             ;;
353
;> remote_list_buf = buffer containing last incomplete entry (if any)                             ;;
354
;;------------------------------------------------------------------------------------------------;;
355
;< none                                                                                           ;;
356
;;================================================================================================;;
357
 
358
        push    edx
359
        push    eax
360
        ; check if any incomplete entry to be parsed
361
        cmp     byte[remote_list_buf], 0
362
        je      .no_backlog
363
        ; find end of remote_list_buf
364
        mov     edi, remote_list_buf
365
        mov     al, 0
366
        repne   scasb
367
        ; copy rest of the incomplete entry to remote_list_buf
368
        mov     esi, buf_buffer2
369
        dec     edi
370
 
371
      @@:
372
        movsb
373
        cmp     word[esi-2], 0x0a0d
374
        jne     @b
375
        mov     byte[edi], 0
376
        mov     ecx, edi
377
        sub     ecx, remote_list_buf ; ecx = length of remote_list_buf
378
        mov     ebx, esi ; ebx = address at which next parse should start
379
        mov     edi, remote_list_buf
380
        jmp     .start_parsing
381
 
382
      .no_backlog:
383
        mov     ecx, eax    ; ecx = number of bytes remaining to parse in buf_buffer2
384
        mov     edi, buf_buffer2
385
 
386
      .start_parsing:
387
        ; find pointer to name
388
        cmp     byte[edi], 'd' ; file is a directory
389
        je      @f
390
        cmp     byte[edi], 'l' ; link
391
        je      @f
392
        mov     word[node_entry2], 'fi'
393
        jmp     .parse
394
 
395
      @@:
396
        mov     word[node_entry2], 'fo'
397
 
398
      .parse:
399
        mov     edx, 8
400
 
401
      @@:
402
        mov     al, ' '
403
        mov     ecx, [esp]
404
        add     ecx, buf_buffer2
405
        sub     ecx, edi
406
 
407
        repne   scasb
408
 
409
        ; check if the (last) entry is incomplete
410
        test    ecx, ecx
411
        jz      .store_last_entry
412
 
413
        rep     scasb
414
        test    ecx, ecx
415
        jz      .store_last_entry
416
 
417
        dec     edx
418
        jnz     @b
419
 
420
        lea     esi, [edi-1]
421
        lea     edi, [node_entry2+4]
422
      @@:
423
        movsb
424
        cmp     word[esi], 0x0a0d ; end of entry
425
        jne     @b
426
        mov     byte[edi], 0
427
 
428
        ; add node to tree list
429
        cmp     word[node_entry2], 'fi'
430
        jne     @f
431
        stdcall dword[tl_node_add], tree2, 0, node_entry2
432
        jmp     .added_remote_node
433
 
434
      @@:
435
        stdcall dword[tl_node_add], tree2, 0x10000, node_entry2
436
 
437
      .added_remote_node:
438
        ; check whether we are parsing remote_list_buf
439
        cmp     byte[remote_list_buf], 0
440
        je      @f
441
        mov     byte[remote_list_buf], 0 ; done parsing remote_list_buf
442
        mov     edi, ebx
443
        mov     eax, [esp]
444
        mov     ecx, buf_buffer2
445
        add     ecx, eax
446
        sub     ecx, ebx
447
        jmp     .start_parsing
448
 
449
      @@:
450
        ; any more entries to parse?
451
        lea     edi, [esi+2] ; skip 0a0d
452
        cmp     byte[edi], 0
453
        jne     .start_parsing
454
        jmp     .done_parsing
455
 
456
      .store_last_entry:
457
        ; find index of the last incomplete entry
458
        mov     ecx, -1
459
        mov     eax, [esp]
460
        lea     edi, [buf_buffer2+eax-2]
461
        mov     al, 0x0a
462
        std
463
        repne   scasb
464
        cld
465
 
466
        ; copy last (incomplete) entry of buf_buffer2 to remote_list_buf
467
        lea     esi, [edi+2]
468
        mov     edi, remote_list_buf
469
      @@:
470
        movsb
471
        cmp     byte[esi-1], 0
472
        jne     @b
473
 
474
      .done_parsing:
475
        call    .draw ; to update tree list immediately in case of "auto_list"
476
        pop     eax
477
        pop     edx
478
        jmp     data_loop
479
 
480
        ; clear tree list and add ".." node before executing "LIST"
481
      .clear_remote_tree:
482
        stdcall dword[tl_info_clear], tree2
483
        mov     dword[node_entry2+4], 0x2E2E
484
        stdcall dword[tl_node_add], tree2, 0x10000, node_entry2
485
        ret
486
 
487
 
488
;;================================================================================================;;
489
    .progress: ;//////////////////////////////////////////////////////////////////////////////////;;
490
;;------------------------------------------------------------------------------------------------;;
491
;? Update progress bar every time new data is received from data_loop block                       ;;
492
;;------------------------------------------------------------------------------------------------;;
493
;> edx = no. of bytes downloaded                                                                  ;;
494
;;------------------------------------------------------------------------------------------------;;
495
;< none                                                                                           ;;
496
;;================================================================================================;;
497
 
498
        ; detect abort
499
        mcall   17
500
        cmp     ah, 10
501
        je      cmd_abor
502
 
503
        push    eax ebx ecx edx
504
        mov     ebx, [file_size]
505
        mov     ecx, 100
506
        mov     eax, edx
507
        mul     ecx
508
        div     ebx
509
        cmp     eax, 100
510
        jle     @f
511
        mov     eax, 100
512
 
513
      @@:
514
        mov     dword[pb], eax
515
        push    pb
516
        call    [progressbar_draw]
517
        pop     edx ecx ebx eax
518
        ret
519
 
520
 
521
remove_dir:
522
 
523
    stdcall dword[tl_node_get_data], tree2
524
    cmp     word[eax], 'fo'
525
    jne     gui.still
526
    lea     esi, [eax+4]
527
    lea     edi, [buf_cmd+4]
528
  @@:
529
    movsb
530
    cmp     byte[esi], 0
531
    jne     @b
532
    mov     word[edi], 0x000a
533
    jmp     cmd_rmd
534
 
535
 
536
delete_file:
537
 
538
    stdcall dword[tl_node_get_data], tree2
539
    cmp     word[eax], 'fi'
540
    jne     gui.still
541
    lea     esi, [eax+4]
542
    lea     edi, [buf_cmd+5]
543
  @@:
544
    movsb
545
    cmp     byte[esi], 0
546
    jne     @b
547
    mov     word[edi], 0x000a
548
    jmp     cmd_dele
549
 
550
 
551
create_remote_dir:
552
 
553
    lea     edi, [buf_cmd+4]
554
    mov     esi, new_dir_buf
555
  @@:
556
    movsb
557
    cmp     byte[esi], 0
558
    jne     @b
559
    mov     word[edi], 0x000a
560
    jmp     cmd_mkd
561
 
562
 
563
; Function to call when you press [Enter]
564
align 4
565
fun_on_enter:
566
 
567
    stdcall dword[tl_node_get_data], tree1
568
    cmp     word[eax], 'fi'
569
    je      @f
570
    lea     ecx, [eax+4] ; discard first 4 bytes
571
    call    populate_local_tree_list.read_new_dir
572
    ;stdcall dword[tl_draw], tree1
573
    ret
574
 
575
  @@:
576
    lea     esi, [eax+4]
577
    lea     edi, [buf_cmd+5]
578
  @@:
579
    movsb
580
    cmp     byte[esi], 0
581
    jne     @b
582
    mov     word[edi], 0x000a
583
    jmp     cmd_stor
584
 
585
 
586
; Function to call when you press [Enter]
587
; for treelist with remote directory listing
588
align 4
589
fun_on_enter2:
590
 
591
    stdcall dword[tl_node_get_data], tree2
592
    lea     esi, [eax+4]
593
    cmp     dword[esi], 0x2E2E
594
    jne     @f
595
    mov     [auto_list], 1
596
    jmp     cmd_cdup
597
 
598
  @@:
599
    cmp     word[eax], 'fo'
600
    je      @f
601
    lea     edi, [buf_cmd+5]
602
    jmp     .copy
603
 
604
  @@:
605
    lea     edi, [buf_cmd+4]
606
 
607
  .copy:
608
    movsb
609
    cmp     byte[esi], 0
610
    jne     .copy
611
    mov     word[edi], 0x000a ; extra character before 0 to compensate for
612
                                ; newline in console code
613
    cmp     word[eax], 'fo'
614
    je      @f
615
    jmp     cmd_retr
616
 
617
  @@:
618
    stdcall dword[tl_info_clear], tree2
619
    mov     [auto_list], 1
620
    jmp     cmd_cwd
621
 
622
 
623
;;================================================================================================;;
624
populate_local_tree_list: ;///////////////////////////////////////////////////////////////////////;;
625
;;------------------------------------------------------------------------------------------------;;
626
;? Update tree1 with file names from current working directory                                    ;;
627
;;------------------------------------------------------------------------------------------------;;
628
;> none                                                                                           ;;
629
;;------------------------------------------------------------------------------------------------;;
630
;< none                                                                                           ;;
631
;;================================================================================================;;
632
 
633
    mov     [filestruct.subfn], 1
634
    mov     [filestruct.size], 32
635
    mov     [filestruct.ptr], folder_data
636
    mov     ecx, root_dir
637
 
638
  .read_new_dir: ; ecx = pointer to folder name
639
    ; parse ".."
640
    cmp     word[ecx], '..'
641
    jne     @f
642
    cmp     byte[ecx+2], 0
643
    jne     @f
644
 
645
    ; removes last file name from filestruct.name
646
    mcall   30, 2, filestruct.name,1024 ; get absolute path for cwd
647
    lea     edi, [filestruct.name+eax] ; edi = pointer to the tail of file name
648
    mov     al, '/'
649
    mov     ecx, -1
650
    std
651
    repne   scasb
652
    cld
653
    mov     byte[edi+1], 0
654
    mov     ecx, filestruct.name
655
 
656
  @@:
657
    mcall   30, 1, ; set cwd
658
    mcall   30, 2, filestruct.name, 1024 ; get absolute path for cwd
659
    ; clear all nodes in tree list
660
    stdcall dword[tl_info_clear], tree1
661
    mov     [filestruct.offset], 0
662
 
663
  ; read 32 blocks
664
  .outer:
665
    mcall   70, filestruct
666
    ;int3
667
    test    eax, eax
668
    jz      @f
669
    cmp     eax, 6 ; EOF
670
    je      @f
671
    call    error_fs
672
    jmp     .done
673
  @@:
674
    test    ebx, ebx
675
    je      .done ; when no. of blocks is multiple of 32
676
    add     [filestruct.offset], ebx
677
    mov     ecx, ebx
678
    mov     edx, folder_data+32+40 ; pointer to first file's name in BDFE
679
 
680
  .inner:   ; ebx = total number of BDFEs
681
            ; ecx = number of BDFEs remaining
682
            ; edx = pointer to file's name in BDFE
683
    ; ignore "." entry
684
    cmp     word[edx], 0x002E
685
    je      .added
686
    ; copy file/folder name to node_entry
687
    mov     esi, edx
688
    mov     edi, node_entry+4
689
  @@:
690
    movsb
691
    cmp     byte [esi-1], 0
692
    jne     @b
693
    ; check whether this is a file or a folder
694
    mov     al, byte[edx-40]
695
    and     al, 0x10
696
    jz      @f
697
    ; add a folder to tree
698
    mov     word[node_entry], 'fo'
699
    stdcall dword[tl_node_add], tree1, 0x10000, node_entry
700
    jmp     .added
701
 
702
  @@:
703
    ; add a file to tree
704
    mov     word[node_entry], 'fi'
705
    stdcall dword[tl_node_add], tree1, 0, node_entry
706
 
707
  .added:
708
    add     edx, 304 ; 304 = length of BDFE. jump to next file's name
709
    loop    .inner
710
    stdcall dword[tl_draw], tree1
711
    cmp     ebx, 32
712
    je      .outer ; more BDFEs to come
713
 
714
  .done:
715
    ret
716
 
717
 
718
MIN_M_WND_H equ 500 ;
719
;input:
720
; edi = pointer to tedit struct
721
align 4
722
EvSize:
723
    pushad
724
    mov     ebx, ted_scr_h
725
    mov     esi, ted_scr_w
726
 
727
    m2m     ted_wnd_w, [procinfo.client_box.width]
728
    mov     eax, ted_wnd_l
729
    sub     ted_wnd_w, eax
730
    sub     ted_wnd_w, 70
731
    movzx   eax, word[esi+sb_offs_size_x]
732
    sub     ted_wnd_w, eax
733
 
734
    ;m2m    ted_wnd_h,[procinfo.client_box.height] ;
735
    ;cmp    ted_wnd_h,MIN_M_WND_H
736
    ;jg     @f
737
    mov     ted_wnd_h, MIN_M_WND_H
738
    ;@@:
739
 
740
    movzx   eax, word[ebx+sb_offs_size_y]
741
    sub     ted_wnd_h, eax
742
    mov     eax, ted_wnd_t
743
    sub     ted_wnd_h, eax
744
 
745
    stdcall [ted_init_scroll_bars], tedit0,2
746
 
747
    popad
748
    ret
749
 
750
 
751
;;================================================================================================;;
752
filter_remote_list: ;/////////////////////////////////////////////////////////////////////////////;;
753
;;------------------------------------------------------------------------------------------------;;
754
;? Filter tree list according to pattern specified in 'filter'                                    ;;
755
;;------------------------------------------------------------------------------------------------;;
756
;> none                                                                                           ;;
757
;;------------------------------------------------------------------------------------------------;;
758
;< none                                                                                           ;;
759
;;================================================================================================;;
760
        stdcall dword[tl_cur_beg], tree2
761
 
762
    .next_node:
763
        stdcall dword[tl_node_get_data], tree2
764
        ; check whether any nodes left
765
        test    eax, eax
766
        jnz     @f
767
        stdcall dword[tl_draw], tree2
768
        stdcall dword[edit_box_set_text], edit_search, str_null
769
        je      gui.still
770
 
771
    @@:
772
        cmp     byte[filter], 0
773
        je      gui.still
774
 
775
        ; calculate size of node entry
776
        lea     esi, [eax+4]
777
        mov     edi, esi
778
        mov     ecx, -1
779
    @@:
780
        lodsb
781
        inc     ecx
782
        test    al, al
783
        jnz     @b
784
 
785
        ; calculate size of pattern
786
        mov     esi, filter
787
        mov     edx, -1
788
    @@:
789
        lodsb
790
        inc     edx
791
        test    al, al
792
        jnz     @b
793
 
794
        mov     esi, filter
795
 
796
        call    search
797
        pop     esi
798
        test    al, al
799
 
800
        jnz     .get_next
801
        stdcall dword[tl_node_delete], tree2
802
        jmp     @f
803
 
804
    .get_next:
805
        stdcall dword[tl_cur_next], tree2
806
 
807
    @@:
808
        jmp     .next_node
809
 
810
 
811
;;================================================================================================;;
812
search: ;/////////////////////////////////////////////////////////////////////////////////////////;;
813
;;------------------------------------------------------------------------------------------------;;
814
;? Search for a substring within a string                                                         ;;
815
;;------------------------------------------------------------------------------------------------;;
816
;> edi = pointer to haystack                                                                      ;;
817
;> ecx = size of haystack                                                                         ;;
818
;> esi = pointer to needle                                                                        ;;
819
;> edx = size of needle                                                                           ;;
820
;;------------------------------------------------------------------------------------------------;;
821
;< al = 0 (not found) / 1 (found)                                                                 ;;
822
;;================================================================================================;;
823
 
824
    push    ebx ecx edx esi edi
825
    ; if length of haystack < length of needle
826
    cmp     ecx, edx
827
    jge     @f
828
    mov     bh, 0
829
    jmp     .done
830
  @@:
831
    mov     bh, 1 ; flag (0 = not found, 1 = found)
832
    sub     ecx, edx
833
    dec     edi
834
 
835
  .outer:
836
    cmp     ecx, 0
837
    jl      .done
838
    dec     ecx
839
    inc     edi
840
    mov     bh, 1 ; flag (0 = not found, 1 = found)
841
    mov     edx, [esp+8]
842
    mov     esi, [esp+4]
843
 
844
  .inner:
845
    test    edx, edx
846
    jz      .done
847
    dec     edx
848
 
849
    mov     eax, esi
850
    sub     eax, [esp+4]
851
    mov     al, byte[edi+eax]
852
    mov     bl, byte[esi]
853
 
854
    inc     esi
855
    cmp     al, bl
856
    je      .inner
857
    mov     bh, 0
858
    jmp     .outer
859
 
860
 
861
  .done:
862
    mov     al, bh
863
    pop     edi esi edx ecx ebx
864
    ret
865
 
866
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
867
 
868
hed             db 'FTP Client - KolibriOS',0
869
str_change      db 'Change',0
870
str_disconnect  db 'Disconnect',0
871
str_copy        db 'Copy',0
872
str_mkd         db 'MKD',0
873
str_dele        db 'DELE',0
874
str_rdir        db 'RDIR',0
875
str_rmd         db 'RMD',0
876
str_abort       db 'Cancel',0
877
str_search      db 'Search',0
878
str_list        db 'LIST',0
879
str_null        db 0
880
 
881
;----------------------
882
; tree list elements
883
;----------------------
884
tree1 tree_list 64, 500, tl_list_box_mode, 16, 16, \
885
    0xffffff, BT_COL, 0x000000, TLIST1_X, 105, TLIST_SZ-16, 185, 14, 4,\
886
    0, el_focus, wScr, fun_on_enter
887
 
888
tree2 tree_list 64, 500, tl_list_box_mode, 16, 16, \
889
    0xffffff, BT_COL, 0x000000, TLIST2_X, 105, TLIST_SZ-16, 185, 14, 4, \
890
    0, el_focus, wScr2, fun_on_enter2
891
 
892
; editbox for mkd
893
edit_mkd edit_box TLIST_SZ-45, TLIST2_X, 82, 0xffffff, 0x6a9480, 0, \
894
    0xAABBCC, 0, 99, new_dir_buf, mouse_dd, 0
895
 
896
; editbox for default volume
897
edit_volume edit_box TLIST_SZ-60, TLIST1_X, 105-20, 0xffffff, 0x6a9480, 0, \
898
    0xAABBCC, 0, 99, root_dir, mouse_dd, 0
899
 
900
; editbox for search
901
edit_search edit_box TLIST_SZ-60, TLIST2_X, 25, 0xffffff, 0x6a9480, 0, \
902
    0xAABBCC, 0, 99, filter,mouse_dd, 0
903
 
904
; A subsidiary structure for scrolling
905
align 4
906
wScr:
907
    .x:
908
    .size_x     dw 16 ;+0
909
    .start_x    dw 250+50-16 ;+2
910
    .y:
911
    .size_y     dw 185 ;+4
912
    .start_y    dw 105 ;+6
913
    .btn_high   dd 15 ;+8
914
    .type       dd 1  ;+12
915
    .max_area   dd 100  ;+16
916
    .cur_area   dd 30  ;+20
917
    .position   dd 0  ;+24
918
    .bckg_col   dd 0xeeeeee ;+28
919
    .frnt_col   dd 0xbbddff ;+32
920
    .line_col   dd 0  ;+36
921
    .redraw     dd 0  ;+40
922
    .delta      dw 0  ;+44
923
    .delta2     dw 0  ;+46
924
    .run_x:
925
    .r_size_x   dw 0  ;+48
926
    .r_start_x  dw 0  ;+50
927
    .run_y:
928
    .r_size_y   dw 0 ;+52
929
    .r_start_y  dw 0 ;+54
930
    .m_pos      dd 0 ;+56
931
    .m_pos_2    dd 0 ;+60
932
    .m_keys     dd 0 ;+64
933
    .run_size   dd 0 ;+68
934
    .position2  dd 0 ;+72
935
    .work_size  dd 0 ;+76
936
    .all_redraw dd 0 ;+80
937
    .ar_offset  dd 1 ;+84
938
 
939
align 4
940
wScr2:
941
    .x:
942
    .size_x     dw 16 ;+0
943
    .start_x    dw 675+50-16 ;+2
944
    .y:
945
    .size_y     dw 185 ;+4
946
    .start_y    dw 105 ;+6
947
    .btn_high   dd 15 ;+8
948
    .type       dd 1  ;+12
949
    .max_area   dd 100  ;+16
950
    .cur_area   dd 30  ;+20
951
    .position   dd 0  ;+24
952
    .bckg_col   dd 0xeeeeee ;+28
953
    .frnt_col   dd 0xbbddff ;+32
954
    .line_col   dd 0  ;+36
955
    .redraw     dd 0  ;+40
956
    .delta      dw 0  ;+44
957
    .delta2     dw 0  ;+46
958
    .run_x:
959
    .r_size_x   dw 0  ;+48
960
    .r_start_x  dw 0  ;+50
961
    .run_y:
962
    .r_size_y   dw 0 ;+52
963
    .r_start_y  dw 0 ;+54
964
    .m_pos      dd 0 ;+56
965
    .m_pos_2    dd 0 ;+60
966
    .m_keys     dd 0 ;+64
967
    .run_size   dd 0 ;+68
968
    .position2  dd 0 ;+72
969
    .work_size  dd 0 ;+76
970
    .all_redraw dd 0 ;+80
971
    .ar_offset  dd 1 ;+84
972
;----------------------
973
; end tree list element
974
;----------------------
975
 
976
;----------------------
977
; textedit elements
978
;----------------------
979
align 4
980
tedit0:
981
    .wnd BOX 50,355,325,240 ;+ 0 195,5+40,325,240
982
    .rec BOX 30,13,7,10   ;+16
983
    .drag_m db 0 ;+32
984
    .drag_k db 0 ;+33
985
    .sel rb 16 ;+34
986
    .seln rb 16 ;+50
987
    .tex      dd 0 ;+66 text memory pointer
988
    .tex_1    dd 0 ;+70 text first symbol pointer
989
    .tex_end  dd 0 ;+74 text end memory pointer
990
    .cur_x    dd 0 ;+78
991
    .cur_y    dd 0 ;+82
992
    .max_chars dd 4096 ;+86
993
    .count_colors_text dd 1 ;+90
994
    .count_key_words   dd 0 ;+94
995
    .color_cursor      dd SYS_COL  ;+98
996
    .color_wnd_capt    dd BT_COL   ;+102
997
    .color_wnd_work    dd 0xffffff ;+106
998
    .color_wnd_bord    dd 0x737373 ;+110
999
    .color_select      dd 0x0000ff ;+114
1000
    .color_cur_text    dd 0xffff00 ;+118
1001
    .color_wnd_text    dd 0x000000 ;+122
1002
    .syntax_file       dd 0 ;+126
1003
    .syntax_file_size  dd 500 ;+130
1004
    .text_colors       dd 0 ;+134
1005
    .help_text_f1      dd 0 ;+138
1006
    .help_id       dd -1 ;+142
1007
    .key_words_data    dd 0 ;+146
1008
    .tim_ch      dd ? ;+150
1009
    .tim_undo    dd ? ;+154
1010
    .tim_ls      dd ? ;+158
1011
    .tim_co      dd ? ;+162
1012
    .el_focus    dd el_focus ;+166
1013
    .err_save    db 0 ;+170
1014
    .panel_id    db 0 ;+171
1015
    .key_new     db 0 ;+172
1016
    .symbol_new_line db 20 ;+173
1017
    .scr_w       dd scrol_w1 ;+174
1018
    .scr_h       dd scrol_h1 ;+178
1019
    .arr_key_pos dd 0 ;+182
1020
    .buffer      dd ed_buffer ;+186
1021
    .buffer_find dd 0 ;+190
1022
    .cur_ins     db 1 ;+194
1023
    .mode_color  db 1 ;+195
1024
    .mode_invis  db 0 ;+196
1025
    .gp_opt      db 0 ;+197
1026
    dd 0;.fun_on_key_ctrl_o dd but_ctrl_o ;+198
1027
    .fun_on_key_ctrl_f dd 0 ;+202 ... Ctrl+F
1028
    dd 0;.fun_on_key_ctrl_n dd but_ctrl_n ;+206 ... Ctrl+N
1029
    .fun_on_key_ctrl_s dd 0 ;+210 ... Ctrl+S
1030
    .buffer_size       dd 4096 ;+214
1031
    .fun_find_err      dd 0 ;+218
1032
    .fun_init_synt_err dd 0 ;+222
1033
    .fun_draw_panel_buttons dd 0 ;+226
1034
    .fun_draw_panel_find    dd 0 ;+230
1035
    .fun_draw_panel_syntax  dd 0 ;+234
1036
    .fun_save_err       dd 0 ;+238
1037
    .increase_size dd 1000 ;+242
1038
    .ptr_free_symb dd ? ;+246
1039
    .font_size     dd 16 shl 24 ; +250
1040
 
1041
align 4
1042
scrol_w1:
1043
    .x:
1044
    .size_x   dw 16 ;+0
1045
    .start_x  dw 85 ;+2
1046
    .y:
1047
    .size_y   dw 100 ; +4
1048
    .start_y  dw  15 ; +6
1049
    .btn_high dd  15 ; +8
1050
    .type     dd   1 ;+12
1051
    .max_area dd 100 ;+16
1052
    rb 4+4
1053
    .bckg_col dd 0xeeeeee ;+28
1054
    .frnt_col dd 0xbbddff ;+32
1055
    .line_col dd 0x808080 ;+36
1056
    .redraw   dd   0 ;+40
1057
    .delta    dw   0 ;+44
1058
    .delta2   dw   0 ;+46
1059
    .run_x:
1060
    rb 2*4+4*6
1061
    .all_redraw dd 0 ;+80
1062
    .ar_offset  dd 1 ;+84
1063
;---------------------------------------------------------------------
1064
align 4
1065
scrol_h1:
1066
    .x:
1067
    .size_x     dw 85 ;+0
1068
    .start_x    dw 30 ;+2
1069
    .y:
1070
    .size_y     dw 16 ;+4
1071
    .start_y    dw 100 ;+6
1072
    .btn_high   dd 15 ;+8
1073
    .type       dd 1  ;+12
1074
    .max_area   dd 100 ;+16
1075
    rb 4+4
1076
    .bckg_col   dd 0xeeeeee ;+28
1077
    .frnt_col   dd 0xbbddff ;+32
1078
    .line_col   dd 0x808080 ;+36
1079
    .redraw     dd 0  ;+40
1080
    .delta      dw 0  ;+44
1081
    .delta2     dw 0  ;+46
1082
    .run_x:
1083
    rb 2*4+4*6
1084
    .all_redraw dd 0 ;+80
1085
    .ar_offset  dd 1 ;+84
1086
 
1087
;------------
1088
;Progress bar
1089
;------------
1090
struc pb
1091
{
1092
    dd 0  ; PB_VALUE          equ +0
1093
    dd (TLIST2_X+TLIST1_X+TLIST_SZ)/2-150 ; PB_LEFT equ +4. 150 = PB_WIDTH/2
1094
    dd 315; PB_TOP            equ +8
1095
    dd 300; PB_WIDTH          equ +12
1096
    dd 15 ; PB_HEIGHT         equ +16
1097
    dd ?  ; PB_STYLE          equ +20
1098
    dd 0  ; PB_MIN            equ +24
1099
    dd 100; PB_MAX            equ +28
1100
    dd 0xffffff; PB_BACK_COLOR     equ +32
1101
    dd 0x00ff40; PB_PROGRESS_COLOR equ +36
1102
    dd 0x808080; PB_FRAME_COLOR    equ +40
1103
}
1104
pb pb
1105
 
1106
 
1107
align 4
7167 nisargshah 1108
@IMPORT_GUI_LIBS:
6582 nisargshah 1109
 
7167 nisargshah 1110
library box_lib, 'box_lib.obj', libimg, 'libimg.obj'
6582 nisargshah 1111
 
1112
import  box_lib, \
1113
        edit_box_draw,      'edit_box', \
1114
        edit_box_key,       'edit_box_key', \
1115
        edit_box_mouse,     'edit_box_mouse', \
1116
        edit_box_set_text,  'edit_box_set_text', \
1117
        version_ed,         'version_ed', \
1118
        scrollbar_ver_draw ,'scrollbar_v_draw', \
1119
        scrollbar_ver_mouse,'scrollbar_v_mouse', \
1120
        scrollbar_hor_draw, 'scrollbar_h_draw', \
1121
        scrollbar_hor_mouse,'scrollbar_h_mouse', \
1122
        version_scrollbar,  'version_scrollbar', \
1123
        tl_data_init,       'tl_data_init', \
1124
        tl_data_clear,      'tl_data_clear', \
1125
        tl_info_clear,      'tl_info_clear', \
1126
        tl_key,             'tl_key', \
1127
        tl_mouse,           'tl_mouse', \
1128
        tl_draw,            'tl_draw', \
1129
        tl_node_add,        'tl_node_add', \
1130
        tl_node_set_data,   'tl_node_set_data', \
1131
        tl_node_get_data,   'tl_node_get_data', \
1132
        tl_node_delete,     'tl_node_delete', \
1133
        tl_cur_beg,         'tl_cur_beg', \
1134
        tl_cur_next,        'tl_cur_next', \
1135
        tl_cur_perv,        'tl_cur_perv', \
1136
        tl_node_close_open, 'tl_node_close_open', \
1137
        ted_but_sumb_upper, 'ted_but_sumb_upper', \
1138
        ted_but_sumb_lover, 'ted_but_sumb_lover', \
1139
        ted_can_save,       'ted_can_save', \
1140
        ted_clear,          'ted_clear', \
1141
        ted_delete,         'ted_delete', \
1142
        ted_draw,           'ted_draw', \
1143
        ted_init,           'ted_init', \
1144
        ted_init_scroll_bars, 'ted_init_scroll_bars', \
1145
        ted_init_syntax_file, 'ted_init_syntax_file', \
1146
        ted_is_select,      'ted_is_select', \
1147
        ted_key,            'ted_key', \
1148
        ted_mouse,          'ted_mouse', \
1149
        ted_open_file,      'ted_open_file', \
1150
        ted_save_file,      'ted_save_file', \
1151
        ted_text_add,       'ted_text_add', \
1152
        ted_but_select_word,'ted_but_select_word', \
1153
        ted_but_cut,        'ted_but_cut', \
1154
        ted_but_copy,       'ted_but_copy', \
1155
        ted_but_paste,      'ted_but_paste', \
1156
        ted_but_undo,       'ted_but_undo', \
1157
        ted_but_redo,       'ted_but_redo', \
1158
        ted_but_reverse,    'ted_but_reverse', \
1159
        ted_but_find_next,  'ted_but_find_next', \
1160
        ted_text_colored,   'ted_text_colored', \
1161
        progressbar_draw,   'progressbar_draw'
1162
 
7167 nisargshah 1163
import  libimg, \
1164
        lib_init1         , 'lib_init', \
1165
        img_is_img        , 'img_is_img', \;определяет по данным, может ли библиотека сделать из них изображени \
1166
        img_info          , 'img_info', \
1167
        img_from_file     , 'img_from_file', \
1168
        img_to_file       , 'img_to_file', \
1169
        img_from_rgb      , 'img_from_rgb', \
1170
        img_to_rgb        , 'img_to_rgb', \;преобразование изображения в данные RG \
1171
        img_to_rgb2       , 'img_to_rgb2', \
1172
        img_decode        , 'img_decode', \ ;автоматически определяет формат графических данны \
1173
        img_encode        , 'img_encode', \
1174
        img_create        , 'img_create', \
1175
        img_destroy       , 'img_destroy', \
1176
        img_destroy_layer , 'img_destroy_layer', \
1177
        img_count         , 'img_count', \
1178
        img_lock_bits     , 'img_lock_bits', \
1179
        img_unlock_bits   , 'img_unlock_bits', \
1180
        img_flip          , 'img_flip', \
1181
        img_flip_layer    , 'img_flip_layer', \
1182
        img_rotate        , 'img_rotate', \
1183
        img_rotate_layer  , 'img_rotate_layer', \
1184
        img_draw          , 'img_draw'
6582 nisargshah 1185
 
7167 nisargshah 1186
 
1187
run_file_70 FileInfoBlock ; required for libimg
1188
 
6582 nisargshah 1189
auto_list   db 1 ; to run LIST immediately after CWD
1190
filter      rb 512
1191
root_dir    db '/rd/1'
1192
            rb 507
1193
new_dir_buf rb 512
1194
folder_data rb 32+32*304
1195
node_entry  db '1111'
1196
            rb 512
1197
node_entry2 db '1111'
1198
            rb 512
1199
remote_list_buf rb 1024
7167 nisargshah 1200
file_name   rb 4096 ; required for libimg
6582 nisargshah 1201
conv_tabl   rb 128
1202
ed_buffer   rb 100
1203
tedit_buffer rb 1024
1204
el_focus    dd 0
1205
;-----------------------
1206
 
1207
procinfo        process_information