Subversion Repositories Kolibri OS

Rev

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