Rev 4164 | Rev 4211 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4164 | Rev 4167 | ||
---|---|---|---|
Line 221... | Line 221... | ||
221 | a->a.i.bg_color, a->a.i.flags); break; |
221 | a->a.i.bg_color, a->a.i.flags); break; |
222 | default: break; |
222 | default: break; |
223 | } |
223 | } |
224 | } |
224 | } |
225 | 225 | ||
- | 226 | /** Draw text data to viewport. |
|
- | 227 | * |
|
- | 228 | * @param vport Viewport id |
|
- | 229 | * @param data Text data. |
|
- | 230 | * @param x Leftmost column of the area. |
|
- | 231 | * @param y Topmost row of the area. |
|
- | 232 | * @param w Number of rows. |
|
- | 233 | * @param h Number of columns. |
|
- | 234 | */ |
|
226 | static void draw_text_data(keyfield_t *data) |
235 | static void draw_text_data(keyfield_t *data, unsigned int x, |
- | 236 | unsigned int y, unsigned int w, unsigned int h) |
|
227 | { |
237 | { |
228 | int i, j; |
238 | unsigned int i, j; |
- | 239 | keyfield_t *field; |
|
229 | attrs_t *a0, *a1; |
240 | attrs_t *a0, *a1; |
230 | 241 | ||
231 | serial_goto(0, 0); |
242 | serial_goto(y, x); |
232 | a0 = &data[0].attrs; |
243 | a0 = &data[0].attrs; |
233 | serial_set_attrs(a0); |
244 | serial_set_attrs(a0); |
234 | 245 | ||
235 | for (i = 0; i < scr_height; i++) { |
246 | for (j = 0; j < h; j++) { |
- | 247 | if (j > 0 && w != scr_width) |
|
- | 248 | serial_goto(y, x); |
|
- | 249 | ||
236 | for (j = 0; j < scr_width; j++) { |
250 | for (i = 0; i < w; i++) { |
- | 251 | unsigned int col = x + i; |
|
- | 252 | unsigned int row = y + j; |
|
- | 253 | ||
237 | a1 = &data[i * scr_width + j].attrs; |
254 | field = &data[j * w + i]; |
- | 255 | ||
- | 256 | a1 = &field->attrs; |
|
238 | if (!attrs_same(*a0, *a1)) |
257 | if (!attrs_same(*a0, *a1)) |
239 | serial_set_attrs(a1); |
258 | serial_set_attrs(a1); |
240 | (*putc_function)(data[i * scr_width + j].character); |
259 | (*putc_function)(field->character); |
241 | a0 = a1; |
260 | a0 = a1; |
242 | } |
261 | } |
243 | } |
262 | } |
244 | } |
263 | } |
245 | 264 | ||
246 | int lastcol = 0; |
265 | int lastcol = 0; |
247 | int lastrow = 0; |
266 | int lastrow = 0; |
248 | 267 | ||
249 | #define FB_WRITE_BUF_SIZE 256 |
- | |
250 | static char fb_write_buf[FB_WRITE_BUF_SIZE]; |
- | |
251 | - | ||
252 | static void fb_write(ipc_callid_t rid, ipc_call_t *request) |
- | |
253 | { |
- | |
254 | int row, col; |
- | |
255 | ipc_callid_t callid; |
- | |
256 | size_t len; |
- | |
257 | size_t i; |
- | |
258 | - | ||
259 | row = IPC_GET_ARG1(*request); |
- | |
260 | col = IPC_GET_ARG2(*request); |
- | |
261 | - | ||
262 | if ((col >= scr_width) || (row >= scr_height)) { |
- | |
263 | ipc_answer_0(callid, EINVAL); |
- | |
264 | ipc_answer_0(rid, EINVAL); |
- | |
265 | return; |
- | |
266 | } |
- | |
267 | - | ||
268 | if (!ipc_data_write_receive(&callid, &len)) { |
- | |
269 | ipc_answer_0(callid, EINVAL); |
- | |
270 | ipc_answer_0(rid, EINVAL); |
- | |
271 | return; |
- | |
272 | } |
- | |
273 | - | ||
274 | if (len > FB_WRITE_BUF_SIZE) |
- | |
275 | len = FB_WRITE_BUF_SIZE; |
- | |
276 | if (len >= scr_width - col) |
- | |
277 | len = scr_width - col; |
- | |
278 | - | ||
279 | (void) ipc_data_write_finalize(callid, fb_write_buf, len); |
- | |
280 | - | ||
281 | if ((lastcol != col) || (lastrow != row)) |
- | |
282 | serial_goto(row, col); |
- | |
283 | - | ||
284 | for (i = 0; i < len; i++) { |
- | |
285 | (*putc_function)(fb_write_buf[i]); |
- | |
286 | } |
- | |
287 | - | ||
288 | lastcol = col + len; |
- | |
289 | lastrow = row; |
- | |
290 | - | ||
291 | ipc_answer_1(rid, EOK, len); |
- | |
292 | } |
- | |
293 | - | ||
294 | /** |
268 | /** |
295 | * Main function of the thread serving client connections. |
269 | * Main function of the thread serving client connections. |
296 | */ |
270 | */ |
297 | void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
271 | void serial_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
298 | { |
272 | { |
Line 301... | Line 275... | ||
301 | ipc_call_t call; |
275 | ipc_call_t call; |
302 | keyfield_t *interbuf = NULL; |
276 | keyfield_t *interbuf = NULL; |
303 | size_t intersize = 0; |
277 | size_t intersize = 0; |
304 | 278 | ||
305 | char c; |
279 | char c; |
306 | int newcol; |
- | |
307 | int newrow; |
280 | int col, row, w, h; |
308 | int fgcolor; |
281 | int fgcolor; |
309 | int bgcolor; |
282 | int bgcolor; |
310 | int flags; |
283 | int flags; |
311 | int style; |
284 | int style; |
312 | int i; |
285 | int i; |
Line 343... | Line 316... | ||
343 | continue; |
316 | continue; |
344 | } |
317 | } |
345 | retval = EINVAL; |
318 | retval = EINVAL; |
346 | break; |
319 | break; |
347 | case FB_DRAW_TEXT_DATA: |
320 | case FB_DRAW_TEXT_DATA: |
- | 321 | col = IPC_GET_ARG1(call); |
|
- | 322 | row = IPC_GET_ARG2(call); |
|
- | 323 | w = IPC_GET_ARG3(call); |
|
- | 324 | h = IPC_GET_ARG4(call); |
|
348 | if (!interbuf) { |
325 | if (!interbuf) { |
349 | retval = EINVAL; |
326 | retval = EINVAL; |
350 | break; |
327 | break; |
351 | } |
328 | } |
- | 329 | if (col + w > scr_width || row + h > scr_height) { |
|
- | 330 | retval = EINVAL; |
|
- | 331 | break; |
|
- | 332 | } |
|
352 | draw_text_data(interbuf); |
333 | draw_text_data(interbuf, col, row, w, h); |
- | 334 | lastrow = row + h - 1; |
|
- | 335 | lastcol = col + w; |
|
353 | retval = 0; |
336 | retval = 0; |
354 | break; |
337 | break; |
355 | case FB_PUTCHAR: |
338 | case FB_PUTCHAR: |
356 | c = IPC_GET_ARG1(call); |
339 | c = IPC_GET_ARG1(call); |
357 | newrow = IPC_GET_ARG2(call); |
340 | row = IPC_GET_ARG2(call); |
358 | newcol = IPC_GET_ARG3(call); |
341 | col = IPC_GET_ARG3(call); |
359 | if ((lastcol != newcol) || (lastrow != newrow)) |
342 | if ((lastcol != col) || (lastrow != row)) |
360 | serial_goto(newrow, newcol); |
343 | serial_goto(row, col); |
361 | lastcol = newcol + 1; |
344 | lastcol = col + 1; |
362 | lastrow = newrow; |
345 | lastrow = row; |
363 | (*putc_function)(c); |
346 | (*putc_function)(c); |
364 | retval = 0; |
347 | retval = 0; |
365 | break; |
348 | break; |
366 | case FB_WRITE: |
- | |
367 | fb_write(callid, &call); |
- | |
368 | - | ||
369 | /* Message already answered */ |
- | |
370 | continue; |
- | |
371 | case FB_CURSOR_GOTO: |
349 | case FB_CURSOR_GOTO: |
372 | newrow = IPC_GET_ARG1(call); |
350 | row = IPC_GET_ARG1(call); |
373 | newcol = IPC_GET_ARG2(call); |
351 | col = IPC_GET_ARG2(call); |
374 | serial_goto(newrow, newcol); |
352 | serial_goto(row, col); |
375 | lastrow = newrow; |
353 | lastrow = row; |
376 | lastcol = newcol; |
354 | lastcol = col; |
377 | retval = 0; |
355 | retval = 0; |
378 | break; |
356 | break; |
379 | case FB_GET_CSIZE: |
357 | case FB_GET_CSIZE: |
380 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
358 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
381 | continue; |
359 | continue; |