Subversion Repositories Kolibri OS

Rev

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

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