Subversion Repositories Kolibri OS

Rev

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