Rev 1542 | Rev 1631 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
| Rev 1542 | Rev 1630 | ||
|---|---|---|---|
| Line 35... | Line 35... | ||
| 35 | #include <libc.h> |
35 | #include <libc.h> |
| 36 | #include <stdio.h> |
36 | #include <stdio.h> |
| 37 | 37 | ||
| 38 | #include "sysio.h" |
38 | #include "sysio.h" |
| 39 | 39 | ||
| - | 40 | #define WIDTH 80 |
|
| - | 41 | #define HEIGHT 25 |
|
| - | 42 | ||
| 40 | /* Allow only 1 connection */ |
43 | /* Allow only 1 connection */ |
| 41 | static int client_connected = 0; |
44 | static int client_connected = 0; |
| 42 | 45 | ||
| 43 | static void sysput(char c) |
46 | static void sysput(char c) |
| 44 | { |
47 | { |
| Line 77... | Line 80... | ||
| 77 | 80 | ||
| 78 | snprintf(control, 20, "\033[%dm", mode); |
81 | snprintf(control, 20, "\033[%dm", mode); |
| 79 | sysputs(control); |
82 | sysputs(control); |
| 80 | } |
83 | } |
| 81 | 84 | ||
| - | 85 | static void scroll(int i) |
|
| - | 86 | { |
|
| - | 87 | if (i > 0) { |
|
| - | 88 | curs_goto(HEIGHT-1, 0); |
|
| - | 89 | while (i--) |
|
| - | 90 | sysputs("\033D"); |
|
| - | 91 | } else if (i < 0) { |
|
| - | 92 | curs_goto(0,0); |
|
| - | 93 | while (i++) |
|
| - | 94 | sysputs("\033M"); |
|
| - | 95 | } |
|
| - | 96 | } |
|
| - | 97 | ||
| 82 | /** ANSI terminal emulation main thread */ |
98 | /** ANSI terminal emulation main thread */ |
| 83 | static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
99 | static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall) |
| 84 | { |
100 | { |
| 85 | int retval; |
101 | int retval; |
| 86 | ipc_callid_t callid; |
102 | ipc_callid_t callid; |
| Line 88... | Line 104... | ||
| 88 | char c; |
104 | char c; |
| 89 | int lastcol=0; |
105 | int lastcol=0; |
| 90 | int lastrow=0; |
106 | int lastrow=0; |
| 91 | int newcol,newrow; |
107 | int newcol,newrow; |
| 92 | int fgcolor,bgcolor; |
108 | int fgcolor,bgcolor; |
| - | 109 | int i; |
|
| 93 | 110 | ||
| 94 | if (client_connected) { |
111 | if (client_connected) { |
| 95 | ipc_answer_fast(iid, ELIMIT, 0,0); |
112 | ipc_answer_fast(iid, ELIMIT, 0,0); |
| 96 | return; |
113 | return; |
| 97 | } |
114 | } |
| Line 117... | Line 134... | ||
| 117 | break; |
134 | break; |
| 118 | case FB_CURSOR_GOTO: |
135 | case FB_CURSOR_GOTO: |
| 119 | newrow = IPC_GET_ARG1(call); |
136 | newrow = IPC_GET_ARG1(call); |
| 120 | newcol = IPC_GET_ARG2(call); |
137 | newcol = IPC_GET_ARG2(call); |
| 121 | curs_goto(newrow, newcol); |
138 | curs_goto(newrow, newcol); |
| - | 139 | lastrow = newrow; |
|
| - | 140 | lastcol = newcol; |
|
| 122 | break; |
141 | break; |
| 123 | case FB_GET_CSIZE: |
142 | case FB_GET_CSIZE: |
| 124 | ipc_answer_fast(callid, 0, 25, 80); |
143 | ipc_answer_fast(callid, 0, HEIGHT, WIDTH); |
| 125 | continue; |
144 | continue; |
| 126 | case FB_CLEAR: |
145 | case FB_CLEAR: |
| 127 | clrscr(); |
146 | clrscr(); |
| 128 | retval = 0; |
147 | retval = 0; |
| 129 | break; |
148 | break; |
| 130 | case FB_SET_STYLE: |
149 | case FB_SET_STYLE: |
| 131 | fgcolor = IPC_GET_ARG1(call); |
150 | fgcolor = IPC_GET_ARG1(call); |
| 132 | bgcolor = IPC_GET_ARG2(call); |
151 | bgcolor = IPC_GET_ARG2(call); |
| - | 152 | if (bgcolor == 0xf0f0f0) |
|
| - | 153 | set_style(0); |
|
| 133 | if (fgcolor > bgcolor) |
154 | else if (fgcolor > bgcolor) |
| 134 | set_style(0); |
155 | set_style(0); |
| 135 | else |
156 | else |
| 136 | set_style(7); |
157 | set_style(7); |
| 137 | retval = 0; |
158 | retval = 0; |
| 138 | break; |
159 | break; |
| - | 160 | case FB_SCROLL: |
|
| - | 161 | i = IPC_GET_ARG1(call); |
|
| - | 162 | if (i > HEIGHT || i < -HEIGHT) { |
|
| - | 163 | retval = EINVAL; |
|
| - | 164 | break; |
|
| - | 165 | } |
|
| - | 166 | scroll(i); |
|
| - | 167 | curs_goto(lastrow, lastcol); |
|
| - | 168 | retval = 0; |
|
| - | 169 | break; |
|
| - | 170 | ||
| 139 | default: |
171 | default: |
| 140 | retval = ENOENT; |
172 | retval = ENOENT; |
| 141 | } |
173 | } |
| 142 | ipc_answer_fast(callid,retval,0,0); |
174 | ipc_answer_fast(callid,retval,0,0); |
| 143 | } |
175 | } |
| Line 147... | Line 179... | ||
| 147 | void sysio_init(void) |
179 | void sysio_init(void) |
| 148 | { |
180 | { |
| 149 | async_set_client_connection(sysio_client_connection); |
181 | async_set_client_connection(sysio_client_connection); |
| 150 | clrscr(); |
182 | clrscr(); |
| 151 | curs_goto(0,0); |
183 | curs_goto(0,0); |
| - | 184 | /* Set scrolling region to 0-25 lines */ |
|
| - | 185 | sysputs("\033[0;25r"); |
|
| 152 | } |
186 | } |