Subversion Repositories Kolibri OS

Rev

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

Rev Author Line No. Line
3545 hidnplayr 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
6
;;                                                                 ;;
7
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;          Version 2, June 1991                                   ;;
9
;;                                                                 ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
 
12
 
13
window_create:
14
 
15
; allocate the window data block
16
        mcall   68, 12, sizeof.window_data
17
        test    eax, eax
18
        jz      .fail
19
 
20
; fill it with all zeros
21
        push    eax
22
        mov     edi, eax
23
        mov     ecx, (sizeof.window_data+3)/4
24
        xor     eax, eax
25
        rep     stosd
26
        pop     eax
27
 
28
  .fail:
29
        ret
30
 
31
 
32
window_set_name:    ; esi = ptr to name, ebx = window ptr
33
 
34
        pusha
35
 
36
; Skip heading spaces
37
  .spaceloop:
38
        cmp     byte[esi], ' '
39
        jne     .done
40
        inc     esi
41
        jmp     .spaceloop
42
  .done:
43
 
44
; Now copy it
45
        lea     edi, [ebx + window.name]
46
        mov     ecx, MAX_WINDOWNAME_LEN
47
  .loop:
48
        lodsb
49
        cmp     al, 0x21
50
        jbe     .addzero
51
        stosb
52
        dec     ecx
53
        jnz     .loop
54
  .addzero:
55
        xor     al, al
56
        stosb
57
 
3981 hidnplayr 58
        call    draw_windowtabs         ; redraw it
3545 hidnplayr 59
 
60
        popa
61
 
62
        ret
63
 
64
 
65
 
66
window_refresh:
67
 
68
; set the correct buffer pointers       ; FIXME: what is it good for?
69
        mov     eax, [textbox_width]    ;
70
        imul    eax, 11                 ;
71
        mov     [pos], eax              ;
72
 
73
        mov     eax, [window_print]
74
        mov     eax, [eax + window.data_ptr]
75
        add     eax, window_data.text
76
        mov     [text_start], eax
77
 
78
        ret
79
 
80
 
81
 
3981 hidnplayr 82
window_is_updated:
83
 
3545 hidnplayr 84
        mov     edi, [window_print]
85
        test    [edi + window.flags], FLAG_UPDATED
86
        jnz     .skip
87
 
88
        or      [edi + window.flags], FLAG_UPDATED
89
 
90
; now play a sound :)
91
 
3981 hidnplayr 92
        call    draw_windowtabs         ; highlight updated tabs
3545 hidnplayr 93
  .skip:
94
 
95
        ret
96
 
97
 
3981 hidnplayr 98
 
99
window_close:
100
 
101
; If current window is a channel, send part command to server
102
        mov     esi, [window_active]
103
        cmp     [esi + window.type], WINDOWTYPE_CHANNEL
104
        jne     .not_channel
105
 
106
        lea     esi, [esi + window.name]
107
        call    cmd_usr_part_channel
108
  .not_channel:
109
 
110
; Remove the window (overwrite current structure with trailing ones)
111
        mov     edi, [window_active]
112
        push    [edi + window.data_ptr]         ; remember data ptr so we can free it later
113
        lea     esi, [edi + sizeof.window]
114
        mov     ecx, windows + MAX_WINDOWS*sizeof.window
115
        sub     ecx, esi
116
        rep     movsb
117
 
118
; Completely zero the trailing window block (there will always be one!)
119
        mov     ecx, sizeof.window
120
        xor     al, al
121
        rep     stosb
122
 
123
; free the window data block
124
        pop     ecx
125
        mcall   68, 13
126
 
127
; We closed this window so we need to show another
128
        mov     edi, [window_active]
129
        cmp     [edi + window.data_ptr], 0
130
        jne     @f
131
        sub     edi, sizeof.window
132
        mov     [window_active], edi
133
        mov     [window_print], edi
134
  @@:
135
 
136
; At last, redraw everything
137
        call    draw_window
138
 
139
        ret
140
 
141
 
142
 
143
 
144
; open a window with a given name, if it does not exist, create it
145
; This procedure only affects window_print ptr, not window_active!
146
;
147
; esi = ptr to ASCIIZ windowname
148
window_open:
149
 
150
        push    esi
151
 
152
        mov     edi, esi
153
        call    compare_to_nick
154
        jne     .nochat
155
 
156
        mov     esi, servercommand+1
157
  .nochat:
158
 
159
; now search for window in list
160
        mov     ebx, windows
161
        mov     [window_print], ebx     ; set first window (server window) as default output window
162
  .scanloop:
163
        cmp     [ebx + window.data_ptr], 0
164
        je      .create_it
165
        push    esi
166
        lea     edi, [ebx + window.name]
167
        mov     ecx, MAX_WINDOWNAME_LEN
168
        repe    cmpsb
169
        pop     esi
170
        cmp     byte[edi-1], 0
171
        je      .got_it
172
        add     ebx, sizeof.window
173
        ; TODO: check buffer limits ?
174
        jmp     .scanloop
175
 
176
; create channel window - search for empty slot
177
  .create_it:
178
        mov     ebx, windows
179
        mov     ecx, MAX_WINDOWS
180
  .scanloop2:
181
        cmp     [ebx + window.data_ptr], 0
182
        je      .free_found
183
        add     ebx, sizeof.window
184
        dec     ecx
185
        jnz     .scanloop2
186
; Error: no more available windows!
187
        jmp     .just_skip
188
 
189
  .free_found:
190
        push    ebx
191
        call    window_create
192
        pop     ebx
193
        test    eax, eax
194
        jz      .just_skip
195
        mov     [ebx + window.data_ptr], eax
196
        mov     [ebx + window.type], WINDOWTYPE_CHAT
197
        mov     [ebx + window.flags], 0
198
 
199
        call    window_set_name
200
        mov     [window_print], ebx
201
        call    window_refresh
202
 
203
        call    draw_windowtabs
204
        jmp     .just_skip
205
 
206
; found it!
207
  .got_it:
208
        mov     [window_print], ebx
209
        call    window_refresh
210
 
211
  .just_skip:
212
        pop     esi
213
  .skip1:
214
; skip text
215
        lodsb
216
        test    al, al
217
        jz      .quit
218
        cmp     al, ' '
219
        jne     .skip1
220
        dec     esi
221
; now skip trailing spaces and semicolons
222
  .skip2:
223
        lodsb
224
        test    al, al
225
        jz      .quit
226
        cmp     al, ' '
227
        je      .skip2
228
        cmp     al, ':'
229
        je      .skip2
230
        dec     esi
231
 
232
  .quit:
233
        ret
234
 
235
 
3545 hidnplayr 236
print_text:                             ; eax = start ptr
237
                                        ; dl = end char
238
        pusha
239
  ptr2:
240
        mov     bl, [eax]
241
 
242
        cmp     bl, dl
243
        je      ptr_ret
244
        cmp     bl, 0
245
        je      ptr_ret
246
        call    print_character
247
 
248
        inc     eax
249
        jmp     ptr2
250
 
251
  ptr_ret:
252
        popa
253
        ret
254
 
255
 
256
print_text2:                            ; esi = ptr to ASCIIZ string
257
 
258
        pusha
259
  .loop:
260
        lodsb
261
        test    al, al
262
        jz      .done
263
        mov     bl, al
264
        call    print_character
265
        jmp     .loop
266
 
267
  .done:
268
        popa
269
        ret
270
 
271
 
272
if TIMESTAMP
273
print_timestamp:
274
 
275
        pusha
276
        mcall   3                       ; get system time
277
 
278
        mov     bl, '['
279
        call    print_character
280
        mov     ecx, TIMESTAMP
281
  .loop:
282
        mov     bl, al
283
        shr     bl, 4
284
        add     bl, '0'
285
        call    print_character
286
 
287
        mov     bl, al
288
        and     bl, 0x0f
289
        add     bl, '0'
290
        call    print_character
291
 
292
        dec     ecx
293
        jz      .done
294
 
295
        mov     bl, ':'
296
        call    print_character
297
        shr     eax, 8
298
        jmp     .loop
299
  .done:
300
        mov     bl, ']'
301
        call    print_character
302
        mov     bl, ' '
303
        call    print_character
304
 
305
        popa
306
        ret
307
end if