Subversion Repositories Kolibri OS

Rev

Rev 4060 | Rev 4477 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4060 Rev 4143
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
4
;; Distributed under terms of the GNU General Public License       ;;
4
;; Distributed under terms of the GNU General Public License       ;;
5
;;                                                                 ;;
5
;;                                                                 ;;
-
 
6
;;   Written by hidnplayr@kolibrios.org                            ;;
6
;;                                                                 ;;
7
;;                                                                 ;;
7
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;          Version 2, June 1991                                   ;;
9
;;          Version 2, June 1991                                   ;;
9
;;                                                                 ;;
10
;;                                                                 ;;
10
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 12...
-
 
12
 
-
 
13
 
11
 
14
; in:  window ptr in ebx
Line -... Line 15...
-
 
15
; out: eax = 0 on error
12
 
16
window_create:
13
window_create:
17
 
14
 
18
        push    ebx
-
 
19
; allocate the window data block
15
; allocate the window data block
20
        mcall   68, 12, sizeof.window_data
Line 16... Line 21...
16
        mcall   68, 12, sizeof.window_data
21
        test    eax, eax
17
        test    eax, eax
22
        pop     ebx
18
        jz      .fail
23
        jz      .fail
19
 
24
 
20
; fill it with all zeros
25
; fill it with all zeros
21
        push    eax
26
        push    eax
22
        mov     edi, eax
27
        mov     edi, eax
Line -... Line 28...
-
 
28
        mov     ecx, (sizeof.window_data+3)/4
-
 
29
        xor     eax, eax
-
 
30
        rep     stosd
-
 
31
        pop     eax
-
 
32
 
-
 
33
        mov     [ebx + window.data_ptr], eax
-
 
34
        mov     [ebx + window.flags], 0
-
 
35
 
-
 
36
        add     eax, window_data.text+1         ; let text begin at offset 1, this way the text will be prepended with a 0
-
 
37
        mov     [ebx + window.text_start], eax
-
 
38
        mov     [ebx + window.text_print], eax
-
 
39
        mov     [ebx + window.text_write], eax
-
 
40
        mov     [ebx + window.text_scanned], eax
23
        mov     ecx, (sizeof.window_data+3)/4
41
        mov     [ebx + window.text_lines], 0
24
        xor     eax, eax
42
        mov     [ebx + window.text_line_print], 0
Line 25... Line 43...
25
        rep     stosd
43
        add     eax, TEXT_BUFFERSIZE-1
Line 61... Line 79...
61
 
79
 
Line 62... Line -...
62
        ret
-
 
63
 
-
 
64
 
-
 
65
 
-
 
66
window_refresh:
-
 
67
 
-
 
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
-
 
72
 
-
 
73
; set the textbuffer pointer
-
 
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
        ret
Line 80... Line 81...
80
 
81
 
-
 
82
 
-
 
83
 
81
 
84
window_is_updated:
82
 
85
 
83
window_is_updated:
-
 
84
 
86
        mov     edi, [window_print]
Line 85... Line 87...
85
        mov     edi, [window_print]
87
        cmp     edi, [window_active]
Line 86... Line 88...
86
        test    [edi + window.flags], FLAG_UPDATED
88
        je      .skip
87
        jnz     .skip
89
        test    [edi + window.flags], FLAG_UPDATED
Line 88... Line 90...
88
 
90
        jnz     .skip
Line 89... Line -...
89
        or      [edi + window.flags], FLAG_UPDATED
-
 
90
 
-
 
91
; now play a sound :)
-
 
92
 
-
 
93
        call    draw_windowtabs         ; highlight updated tabs
-
 
94
  .skip:
-
 
95
 
-
 
96
        ret
91
        or      [edi + window.flags], FLAG_UPDATED
97
 
-
 
98
 
-
 
Line 99... Line 92...
99
 
92
 
100
window_close:
93
; TODO: make some noise
101
 
94
 
102
; If current window is a channel, send part command to server
95
        call    draw_windowtabs         ; highlight updated tabs
103
        mov     esi, [window_active]
96
  .skip:
104
        cmp     [esi + window.type], WINDOWTYPE_CHANNEL
97
 
105
        jne     .not_channel
98
        ret
Line 129... Line 122...
129
        mov     edi, [window_active]
122
        mov     edi, [window_active]
130
        cmp     [edi + window.data_ptr], 0
123
        cmp     [edi + window.data_ptr], 0
131
        jne     @f
124
        jne     @f
132
        sub     edi, sizeof.window
125
        sub     edi, sizeof.window
133
        mov     [window_active], edi
126
        mov     [window_active], edi
134
        mov     [window_print], edi
127
        mov     [window_print], edi  ;;;;;;;;
135
  @@:
128
  @@:
Line 136... Line 129...
136
 
129
 
137
; At last, redraw everything
130
; At last, redraw everything
Line 138... Line 131...
138
        call    draw_window
131
        call    draw_window
Line -... Line 132...
-
 
132
 
-
 
133
        ret
-
 
134
 
-
 
135
 
-
 
136
 
-
 
137
window_find:    ; esi = window name
-
 
138
; search for window in list
-
 
139
        mov     ebx, windows
-
 
140
        mov     [window_print], ebx     ; set first window (server window) as default output window
-
 
141
        mov     eax, MAX_WINDOWS
-
 
142
  .scanloop:
-
 
143
        push    esi
-
 
144
        cmp     [ebx + window.type], WINDOWTYPE_NONE
-
 
145
        je      .try_next
-
 
146
        lea     edi, [ebx + window.name]
-
 
147
        mov     ecx, MAX_WINDOWNAME_LEN
-
 
148
        repe    cmpsb
-
 
149
        cmp     byte[edi-1], 0
-
 
150
        jne     .try_next
-
 
151
        cmp     byte[esi-1], 0
-
 
152
        je      .got_it
-
 
153
        cmp     byte[esi-1], 10
-
 
154
        je      .got_it
-
 
155
        cmp     byte[esi-1], 13
-
 
156
        je      .got_it
-
 
157
        cmp     byte[esi-1], ' '
-
 
158
        je      .got_it
-
 
159
  .try_next:
-
 
160
        pop     esi
-
 
161
        add     ebx, sizeof.window
-
 
162
        dec     eax
-
 
163
        jnz     .scanloop
-
 
164
 
-
 
165
        xor     ebx, ebx
-
 
166
        ret
-
 
167
 
-
 
168
  .got_it:
-
 
169
        pop     esi                 ;;; TODO: dont reset ESI  ?
-
 
170
        mov     [window_print], ebx
-
 
171
        ret
Line 139... Line 172...
139
 
172
 
140
        ret
173
 
141
 
174
 
142
 
175
 
Line 155... Line 188...
155
        jne     .nochat
188
        jne     .nochat
Line 156... Line 189...
156
 
189
 
157
        mov     esi, servercommand+1
190
        mov     esi, servercommand+1
Line 158... Line -...
158
  .nochat:
-
 
159
 
191
  .nochat:
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]
192
 
168
        mov     ecx, MAX_WINDOWNAME_LEN
-
 
169
        repe    cmpsb
-
 
170
        pop     esi
193
        call    window_find
171
        cmp     byte[edi-1], 0
-
 
172
        je      .got_it
-
 
173
        add     ebx, sizeof.window
-
 
Line 174... Line 194...
174
        ; TODO: check buffer limits ?
194
        test    ebx, ebx
175
        jmp     .scanloop
195
        jne     .got_it
176
 
196
 
177
; create channel window - search for empty slot
197
; create channel window - search for empty slot
Line 183... Line 203...
183
        je      .free_found
203
        je      .free_found
184
        add     ebx, sizeof.window
204
        add     ebx, sizeof.window
185
        dec     ecx
205
        dec     ecx
186
        jnz     .scanloop2
206
        jnz     .scanloop2
187
; Error: no more available windows!
207
; Error: no more available windows!
188
        jmp     .just_skip
208
        jmp     .got_it ; TODO: return error
Line 189... Line 209...
189
 
209
 
190
  .free_found:
-
 
191
        push    ebx
210
  .free_found:
192
        call    window_create
-
 
193
        pop     ebx
211
        call    window_create
194
        test    eax, eax
-
 
195
        jz      .just_skip
212
        test    eax, eax
196
        mov     [ebx + window.data_ptr], eax
213
        jz      .got_it ; TODO: return error
197
        mov     [ebx + window.type], WINDOWTYPE_CHAT
-
 
Line 198... Line 214...
198
        mov     [ebx + window.flags], 0
214
        mov     [ebx + window.type], WINDOWTYPE_CHAT    ; FIXME: let caller handle this ?
199
 
215
 
200
        call    window_set_name
-
 
Line 201... Line 216...
201
        mov     [window_print], ebx
216
        call    window_set_name
202
        call    window_refresh
-
 
Line 203... Line -...
203
 
-
 
204
        call    draw_windowtabs
217
        mov     [window_print], ebx
205
        jmp     .just_skip
-
 
206
 
-
 
207
; found it!
-
 
208
  .got_it:
-
 
209
        mov     [window_print], ebx
218
 
210
        call    window_refresh
219
        call    draw_windowtabs
211
 
220
 
212
  .just_skip:
221
  .got_it:
213
        pop     esi
222
        pop     esi
Line 230... Line 239...
230
        je      .skip2
239
        je      .skip2
231
        dec     esi
240
        dec     esi
Line 232... Line 241...
232
 
241
 
233
  .quit:
242
  .quit:
234
        ret
-
 
235
 
-
 
236
 
-
 
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
243
        ret