Subversion Repositories Kolibri OS

Rev

Rev 3981 | Rev 4143 | 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
 
4060 hidnplayr 68
; set text write cursor to beginning of last line
69
        mov     eax, [textbox_width]
70
        imul    eax, TEXTBOX_LINES - 1
71
        mov     [text_pos], eax
3545 hidnplayr 72
 
4060 hidnplayr 73
; set the textbuffer pointer
3545 hidnplayr 74
        mov     eax, [window_print]
75
        mov     eax, [eax + window.data_ptr]
76
        add     eax, window_data.text
77
        mov     [text_start], eax
78
 
79
        ret
80
 
81
 
82
 
3981 hidnplayr 83
window_is_updated:
84
 
3545 hidnplayr 85
        mov     edi, [window_print]
86
        test    [edi + window.flags], FLAG_UPDATED
87
        jnz     .skip
88
 
89
        or      [edi + window.flags], FLAG_UPDATED
90
 
91
; now play a sound :)
92
 
3981 hidnplayr 93
        call    draw_windowtabs         ; highlight updated tabs
3545 hidnplayr 94
  .skip:
95
 
96
        ret
97
 
98
 
3981 hidnplayr 99
 
100
window_close:
101
 
102
; If current window is a channel, send part command to server
103
        mov     esi, [window_active]
104
        cmp     [esi + window.type], WINDOWTYPE_CHANNEL
105
        jne     .not_channel
106
 
107
        lea     esi, [esi + window.name]
108
        call    cmd_usr_part_channel
109
  .not_channel:
110
 
111
; Remove the window (overwrite current structure with trailing ones)
112
        mov     edi, [window_active]
113
        push    [edi + window.data_ptr]         ; remember data ptr so we can free it later
114
        lea     esi, [edi + sizeof.window]
115
        mov     ecx, windows + MAX_WINDOWS*sizeof.window
116
        sub     ecx, esi
117
        rep     movsb
118
 
119
; Completely zero the trailing window block (there will always be one!)
120
        mov     ecx, sizeof.window
121
        xor     al, al
122
        rep     stosb
123
 
124
; free the window data block
125
        pop     ecx
126
        mcall   68, 13
127
 
128
; We closed this window so we need to show another
129
        mov     edi, [window_active]
130
        cmp     [edi + window.data_ptr], 0
131
        jne     @f
132
        sub     edi, sizeof.window
133
        mov     [window_active], edi
134
        mov     [window_print], edi
135
  @@:
136
 
137
; At last, redraw everything
138
        call    draw_window
139
 
140
        ret
141
 
142
 
143
 
144
 
145
; open a window with a given name, if it does not exist, create it
146
; This procedure only affects window_print ptr, not window_active!
147
;
148
; esi = ptr to ASCIIZ windowname
149
window_open:
150
 
151
        push    esi
152
 
153
        mov     edi, esi
154
        call    compare_to_nick
155
        jne     .nochat
156
 
157
        mov     esi, servercommand+1
158
  .nochat:
159
 
160
; now search for window in list
161
        mov     ebx, windows
162
        mov     [window_print], ebx     ; set first window (server window) as default output window
163
  .scanloop:
164
        cmp     [ebx + window.data_ptr], 0
165
        je      .create_it
166
        push    esi
167
        lea     edi, [ebx + window.name]
168
        mov     ecx, MAX_WINDOWNAME_LEN
169
        repe    cmpsb
170
        pop     esi
171
        cmp     byte[edi-1], 0
172
        je      .got_it
173
        add     ebx, sizeof.window
174
        ; TODO: check buffer limits ?
175
        jmp     .scanloop
176
 
177
; create channel window - search for empty slot
178
  .create_it:
179
        mov     ebx, windows
180
        mov     ecx, MAX_WINDOWS
181
  .scanloop2:
182
        cmp     [ebx + window.data_ptr], 0
183
        je      .free_found
184
        add     ebx, sizeof.window
185
        dec     ecx
186
        jnz     .scanloop2
187
; Error: no more available windows!
188
        jmp     .just_skip
189
 
190
  .free_found:
191
        push    ebx
192
        call    window_create
193
        pop     ebx
194
        test    eax, eax
195
        jz      .just_skip
196
        mov     [ebx + window.data_ptr], eax
197
        mov     [ebx + window.type], WINDOWTYPE_CHAT
198
        mov     [ebx + window.flags], 0
199
 
200
        call    window_set_name
201
        mov     [window_print], ebx
202
        call    window_refresh
203
 
204
        call    draw_windowtabs
205
        jmp     .just_skip
206
 
207
; found it!
208
  .got_it:
209
        mov     [window_print], ebx
210
        call    window_refresh
211
 
212
  .just_skip:
213
        pop     esi
214
  .skip1:
215
; skip text
216
        lodsb
217
        test    al, al
218
        jz      .quit
219
        cmp     al, ' '
220
        jne     .skip1
221
        dec     esi
222
; now skip trailing spaces and semicolons
223
  .skip2:
224
        lodsb
225
        test    al, al
226
        jz      .quit
227
        cmp     al, ' '
228
        je      .skip2
229
        cmp     al, ':'
230
        je      .skip2
231
        dec     esi
232
 
233
  .quit:
234
        ret
235
 
236
 
3545 hidnplayr 237
 
238
if TIMESTAMP
239
print_timestamp:
240
 
241
        pusha
242
        mcall   3                       ; get system time
243
 
244
        mov     bl, '['
245
        call    print_character
246
        mov     ecx, TIMESTAMP
247
  .loop:
248
        mov     bl, al
249
        shr     bl, 4
250
        add     bl, '0'
251
        call    print_character
252
 
253
        mov     bl, al
254
        and     bl, 0x0f
255
        add     bl, '0'
256
        call    print_character
257
 
258
        dec     ecx
259
        jz      .done
260
 
261
        mov     bl, ':'
262
        call    print_character
263
        shr     eax, 8
264
        jmp     .loop
265
  .done:
266
        mov     bl, ']'
267
        call    print_character
268
        mov     bl, ' '
269
        call    print_character
270
 
271
        popa
272
        ret
273
end if