Subversion Repositories Kolibri OS

Rev

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

Rev 4143 Rev 4477
Line 1... Line 1...
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                                 ;;
2
;;                                                                 ;;
3
;; Copyright (C) KolibriOS team 2004-2013. All rights reserved.    ;;
3
;; Copyright (C) KolibriOS team 2004-2014. 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
;;   Written by hidnplayr@kolibrios.org                            ;;
7
;;                                                                 ;;
7
;;                                                                 ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
8
;;         GNU GENERAL PUBLIC LICENSE                              ;;
9
;;          Version 2, June 1991                                   ;;
9
;;          Version 2, June 1991                                   ;;
10
;;                                                                 ;;
10
;;                                                                 ;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Line -... Line 12...
-
 
12
 
-
 
13
; window_create_textbox
12
 
14
; Initialises the data structure for our multiline textbox
13
 
15
;
14
; in:  window ptr in ebx
16
; in:   window ptr in ebx
-
 
17
; out:  eax = 0 on error
-
 
18
;       ecx, edi = destroyed
15
; out: eax = 0 on error
19
 
Line 16... Line 20...
16
window_create:
20
window_create_textbox:
17
 
21
 
18
        push    ebx
22
        push    ebx
19
; allocate the window data block
23
; allocate the window data block
Line 45... Line 49...
45
 
49
 
46
  .fail:
50
  .fail:
Line -... Line 51...
-
 
51
        ret
47
        ret
52
 
48
 
53
 
-
 
54
; window_set_name
-
 
55
; Fills in the window name in window structure
-
 
56
;
49
 
57
; IN:   esi = ptr to name
-
 
58
;       ebx = window ptr
Line 50... Line -...
50
window_set_name:    ; esi = ptr to name, ebx = window ptr
-
 
51
 
-
 
52
        pusha
-
 
53
 
-
 
54
; Skip heading spaces
-
 
55
  .spaceloop:
-
 
56
        cmp     byte[esi], ' '
59
; OUT:  esi = ptr to next parameter
Line 57... Line -...
57
        jne     .done
-
 
58
        inc     esi
60
;       ebx = window ptr
59
        jmp     .spaceloop
61
;       eax, ecx, edx, edi = destroyed
60
  .done:
62
 
61
 
63
window_set_name:
62
; Now copy it
64
 
63
        lea     edi, [ebx + window.name]
65
        lea     edi, [ebx + window.name]
64
        mov     ecx, MAX_WINDOWNAME_LEN
66
        mov     ecx, MAX_WINDOWNAME_LEN
65
  .loop:
67
  .loop:
66
        lodsb
68
        lodsb
67
        cmp     al, 0x21
69
        cmp     al, 0x21        ; name ends with 0, space or !
68
        jbe     .addzero
70
        jbe     .addzero
69
        stosb
71
        stosb
Line -... Line 72...
-
 
72
        dec     ecx
70
        dec     ecx
73
        jnz     .loop
71
        jnz     .loop
-
 
72
  .addzero:
74
  .addzero:
Line 73... Line 75...
73
        xor     al, al
75
        xor     al, al
Line 131... Line 133...
131
        call    draw_window
133
        call    draw_window
Line 132... Line 134...
132
 
134
 
Line -... Line 135...
-
 
135
        ret
-
 
136
 
-
 
137
 
-
 
138
; window_find:
-
 
139
; search for a window with given name in the window list
-
 
140
;
-
 
141
; IN:   esi = ptr to start of window name
-
 
142
; OUT:  ebx = window ptr, or 0 if none found
Line 133... Line -...
133
        ret
-
 
134
 
-
 
135
 
143
;       esi = ptr to end of window name, if window was found
136
 
-
 
137
window_find:    ; esi = window name
144
 
138
; search for window in list
145
window_find:
139
        mov     ebx, windows
146
 
140
        mov     [window_print], ebx     ; set first window (server window) as default output window
147
        mov     ebx, windows
141
        mov     eax, MAX_WINDOWS
148
        mov     eax, MAX_WINDOWS
142
  .scanloop:
149
  .scanloop:
143
        push    esi
150
        push    esi
144
        cmp     [ebx + window.type], WINDOWTYPE_NONE
151
        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
152
        je      .try_next
154
        je      .got_it
153
        lea     edi, [ebx + window.name]
-
 
154
        mov     ecx, MAX_WINDOWNAME_LEN
-
 
155
        repe    cmpsb
-
 
156
        cmp     byte[edi-1], 0          ; last equall character was null? yes, the strings match!
-
 
157
        je      .got_it
155
        cmp     byte[esi-1], 13
158
        cmp     byte[edi], 0            ; we're at the end of string1.. ?
156
        je      .got_it
159
        jne     .try_next
157
        cmp     byte[esi-1], ' '
160
        cmp     byte[esi], 0x21         ; and the end of string2? yes!
158
        je      .got_it
161
        jbe     .got_it
159
  .try_next:
162
  .try_next:
Line 160... Line 163...
160
        pop     esi
163
        pop     esi
161
        add     ebx, sizeof.window
164
        add     ebx, sizeof.window
Line 162... Line 165...
162
        dec     eax
165
        dec     eax
163
        jnz     .scanloop
-
 
164
 
166
        jnz     .scanloop
165
        xor     ebx, ebx
167
 
Line 166... Line -...
166
        ret
-
 
167
 
-
 
168
  .got_it:
168
        xor     ebx, ebx
169
        pop     esi                 ;;; TODO: dont reset ESI  ?
169
        ret
170
        mov     [window_print], ebx
170
 
171
        ret
171
  .got_it:
172
 
172
        add     esp, 4
173
 
173
        ret
Line 174... Line 174...
174
 
174
 
175
 
-
 
176
 
-
 
177
 
-
 
178
; open a window with a given name, if it does not exist, create it
-
 
Line -... Line 175...
-
 
175
 
-
 
176
 
-
 
177
; window_open:
179
; This procedure only affects window_print ptr, not window_active!
178
; open a window with a given name, if it does not exist, create it
-
 
179
; This procedure only affects window_print ptr, not window_active!
-
 
180
;
180
;
181
; IN:   esi = ptr to ASCIIZ windowname
Line 181... Line 182...
181
; esi = ptr to ASCIIZ windowname
182
; OUT:  esi = ptr to next parameter
182
window_open:
183
 
183
 
184
window_open:
Line 184... Line 185...
184
        push    esi
185
 
185
 
186
; Skip heading spaces
186
        mov     edi, esi
187
        lodsb
187
        call    compare_to_nick
188
        cmp     al, ' '
188
        jne     .nochat
189
        je      window_open
189
 
190
        cmp     al, ':'
190
        mov     esi, servercommand+1
191
        je      window_open
191
  .nochat:
192
        dec     esi
192
 
193
 
193
        call    window_find
194
        call    window_find
194
        test    ebx, ebx
-
 
195
        jne     .got_it
195
        test    ebx, ebx
Line 196... Line 196...
196
 
196
        jnz     .got_it
197
; create channel window - search for empty slot
197
 
198
  .create_it:
198
; create channel window - search for empty slot
199
        mov     ebx, windows
199
  .create_it:
200
        mov     ecx, MAX_WINDOWS
200
        mov     ebx, windows
Line 201... Line 201...
201
  .scanloop2:
201
        mov     ecx, MAX_WINDOWS
202
        cmp     [ebx + window.data_ptr], 0
-
 
203
        je      .free_found
-
 
204
        add     ebx, sizeof.window
-
 
Line 205... Line 202...
205
        dec     ecx
202
  .scanloop2:
206
        jnz     .scanloop2
-
 
207
; Error: no more available windows!
-
 
208
        jmp     .got_it ; TODO: return error
-
 
209
 
-
 
210
  .free_found:
-
 
211
        call    window_create
-
 
212
        test    eax, eax
-
 
213
        jz      .got_it ; TODO: return error
-
 
214
        mov     [ebx + window.type], WINDOWTYPE_CHAT    ; FIXME: let caller handle this ?
-
 
215
 
-
 
216
        call    window_set_name
-
 
217
        mov     [window_print], ebx
203
        cmp     [ebx + window.type], WINDOWTYPE_NONE
218
 
-
 
219
        call    draw_windowtabs
-
 
220
 
204
        je      .free_found
221
  .got_it:
205
        add     ebx, sizeof.window
222
        pop     esi
206
        dec     ecx
223
  .skip1:
207
        jnz     .scanloop2
224
; skip text
208
        jmp     .error
Line -... Line 209...
-
 
209
 
225
        lodsb
210
  .free_found:
-
 
211
        call    window_create_textbox
-
 
212
        test    eax, eax
226
        test    al, al
213
        jz      .error
227
        jz      .quit
214
        mov     [ebx + window.type], WINDOWTYPE_CHAT    ; FIXME: let caller handle this ?