Rev 4327 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4327 | Rev 4581 | ||
---|---|---|---|
Line 41... | Line 41... | ||
41 | #include <ipc/ipc.h> |
41 | #include <ipc/ipc.h> |
42 | #include <async.h> |
42 | #include <async.h> |
43 | #include <ipc/fb.h> |
43 | #include <ipc/fb.h> |
44 | #include <bool.h> |
44 | #include <bool.h> |
45 | #include <errno.h> |
45 | #include <errno.h> |
46 | #include <console/color.h> |
46 | #include <io/color.h> |
47 | #include <console/style.h> |
47 | #include <io/style.h> |
- | 48 | #include <string.h> |
|
48 | 49 | ||
49 | #include "../console/screenbuffer.h" |
50 | #include "../console/screenbuffer.h" |
50 | #include "main.h" |
51 | #include "main.h" |
51 | #include "serial_console.h" |
52 | #include "serial_console.h" |
52 | 53 | ||
Line 126... | Line 127... | ||
126 | (*putc_function)('?'); |
127 | (*putc_function)('?'); |
127 | } |
128 | } |
128 | 129 | ||
129 | } |
130 | } |
130 | 131 | ||
131 | void serial_goto(const unsigned int row, const unsigned int col) |
132 | void serial_goto(const unsigned int col, const unsigned int row) |
132 | { |
133 | { |
133 | if ((row > scr_height) || (col > scr_width)) |
134 | if ((col > scr_width) || (row > scr_height)) |
134 | return; |
135 | return; |
135 | 136 | ||
136 | char control[MAX_CONTROL]; |
137 | char control[MAX_CONTROL]; |
137 | snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1); |
138 | snprintf(control, MAX_CONTROL, "\033[%u;%uf", row + 1, col + 1); |
138 | serial_puts(control); |
139 | serial_puts(control); |
Line 151... | Line 152... | ||
151 | } |
152 | } |
152 | 153 | ||
153 | void serial_scroll(int i) |
154 | void serial_scroll(int i) |
154 | { |
155 | { |
155 | if (i > 0) { |
156 | if (i > 0) { |
156 | serial_goto(scr_height - 1, 0); |
157 | serial_goto(0, scr_height - 1); |
157 | while (i--) |
158 | while (i--) |
158 | serial_puts("\033D"); |
159 | serial_puts("\033D"); |
159 | } else if (i < 0) { |
160 | } else if (i < 0) { |
160 | serial_goto(0, 0); |
161 | serial_goto(0, 0); |
161 | while (i++) |
162 | while (i++) |
Line 233... | Line 234... | ||
233 | static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor) |
234 | static void serial_set_rgb(uint32_t fgcolor, uint32_t bgcolor) |
234 | { |
235 | { |
235 | if (fgcolor < bgcolor) |
236 | if (fgcolor < bgcolor) |
236 | serial_sgr(SGR_REVERSE_OFF); |
237 | serial_sgr(SGR_REVERSE_OFF); |
237 | else |
238 | else |
238 | serial_sgr(SGR_REVERSE); |
239 | serial_sgr(SGR_REVERSE); |
239 | } |
240 | } |
240 | 241 | ||
241 | static void serial_set_attrs(const attrs_t *a) |
242 | static void serial_set_attrs(const attrs_t *a) |
242 | { |
243 | { |
243 | switch (a->t) { |
244 | switch (a->t) { |
- | 245 | case at_style: |
|
244 | case at_style: serial_set_style(a->a.s.style); break; |
246 | serial_set_style(a->a.s.style); |
- | 247 | break; |
|
- | 248 | case at_rgb: |
|
245 | case at_rgb: serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); break; |
249 | serial_set_rgb(a->a.r.fg_color, a->a.r.bg_color); |
- | 250 | break; |
|
- | 251 | case at_idx: |
|
246 | case at_idx: serial_set_idx(a->a.i.fg_color, |
252 | serial_set_idx(a->a.i.fg_color, |
247 | a->a.i.bg_color, a->a.i.flags); break; |
253 | a->a.i.bg_color, a->a.i.flags); |
- | 254 | break; |
|
248 | default: break; |
255 | default: |
- | 256 | break; |
|
249 | } |
257 | } |
250 | } |
258 | } |
251 | 259 | ||
252 | /** Draw text data to viewport. |
260 | /** Draw text data to viewport. |
253 | * |
261 | * |
Line 263... | Line 271... | ||
263 | { |
271 | { |
264 | unsigned int i, j; |
272 | unsigned int i, j; |
265 | keyfield_t *field; |
273 | keyfield_t *field; |
266 | attrs_t *a0, *a1; |
274 | attrs_t *a0, *a1; |
267 | 275 | ||
268 | serial_goto(y, x); |
276 | serial_goto(x, y); |
269 | a0 = &data[0].attrs; |
277 | a0 = &data[0].attrs; |
270 | serial_set_attrs(a0); |
278 | serial_set_attrs(a0); |
271 | 279 | ||
272 | for (j = 0; j < h; j++) { |
280 | for (j = 0; j < h; j++) { |
273 | if (j > 0 && w != scr_width) |
281 | if (j > 0 && w != scr_width) |
274 | serial_goto(y, x); |
282 | serial_goto(x, j); |
275 | 283 | ||
276 | for (i = 0; i < w; i++) { |
284 | for (i = 0; i < w; i++) { |
277 | field = &data[j * w + i]; |
285 | field = &data[j * w + i]; |
278 | 286 | ||
279 | a1 = &field->attrs; |
287 | a1 = &field->attrs; |
Line 352... | Line 360... | ||
352 | if (col + w > scr_width || row + h > scr_height) { |
360 | if (col + w > scr_width || row + h > scr_height) { |
353 | retval = EINVAL; |
361 | retval = EINVAL; |
354 | break; |
362 | break; |
355 | } |
363 | } |
356 | draw_text_data(interbuf, col, row, w, h); |
364 | draw_text_data(interbuf, col, row, w, h); |
357 | lastrow = row + h - 1; |
- | |
358 | lastcol = col + w; |
365 | lastcol = col + w; |
- | 366 | lastrow = row + h - 1; |
|
359 | retval = 0; |
367 | retval = 0; |
360 | break; |
368 | break; |
361 | case FB_PUTCHAR: |
369 | case FB_PUTCHAR: |
362 | c = IPC_GET_ARG1(call); |
370 | c = IPC_GET_ARG1(call); |
363 | row = IPC_GET_ARG2(call); |
371 | col = IPC_GET_ARG2(call); |
364 | col = IPC_GET_ARG3(call); |
372 | row = IPC_GET_ARG3(call); |
365 | if ((lastcol != col) || (lastrow != row)) |
373 | if ((lastcol != col) || (lastrow != row)) |
366 | serial_goto(row, col); |
374 | serial_goto(col, row); |
367 | lastcol = col + 1; |
375 | lastcol = col + 1; |
368 | lastrow = row; |
376 | lastrow = row; |
369 | serial_putchar(c); |
377 | serial_putchar(c); |
370 | retval = 0; |
378 | retval = 0; |
371 | break; |
379 | break; |
372 | case FB_CURSOR_GOTO: |
380 | case FB_CURSOR_GOTO: |
373 | row = IPC_GET_ARG1(call); |
381 | col = IPC_GET_ARG1(call); |
374 | col = IPC_GET_ARG2(call); |
382 | row = IPC_GET_ARG2(call); |
375 | serial_goto(row, col); |
383 | serial_goto(col, row); |
376 | lastrow = row; |
- | |
377 | lastcol = col; |
384 | lastcol = col; |
- | 385 | lastrow = row; |
|
378 | retval = 0; |
386 | retval = 0; |
379 | break; |
387 | break; |
380 | case FB_GET_CSIZE: |
388 | case FB_GET_CSIZE: |
381 | ipc_answer_2(callid, EOK, scr_height, scr_width); |
389 | ipc_answer_2(callid, EOK, scr_width, scr_height); |
382 | continue; |
390 | continue; |
383 | case FB_CLEAR: |
391 | case FB_CLEAR: |
384 | serial_clrscr(); |
392 | serial_clrscr(); |
385 | retval = 0; |
393 | retval = 0; |
386 | break; |
394 | break; |
Line 414... | Line 422... | ||
414 | if ((i > scr_height) || (i < -scr_height)) { |
422 | if ((i > scr_height) || (i < -scr_height)) { |
415 | retval = EINVAL; |
423 | retval = EINVAL; |
416 | break; |
424 | break; |
417 | } |
425 | } |
418 | serial_scroll(i); |
426 | serial_scroll(i); |
419 | serial_goto(lastrow, lastcol); |
427 | serial_goto(lastcol, lastrow); |
420 | retval = 0; |
428 | retval = 0; |
421 | break; |
429 | break; |
422 | case FB_CURSOR_VISIBILITY: |
430 | case FB_CURSOR_VISIBILITY: |
423 | if(IPC_GET_ARG1(call)) |
431 | if(IPC_GET_ARG1(call)) |
424 | serial_cursor_enable(); |
432 | serial_cursor_enable(); |
Line 443... | Line 451... | ||
443 | } |
451 | } |
444 | ipc_answer_0(callid, retval); |
452 | ipc_answer_0(callid, retval); |
445 | } |
453 | } |
446 | } |
454 | } |
447 | 455 | ||
448 | /** |
456 | /** |
449 | * @} |
457 | * @} |
450 | */ |
458 | */ |