Subversion Repositories HelenOS-historic

Rev

Rev 1492 | Rev 1500 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1492 Rev 1498
Line 38... Line 38...
38
#include "sysio.h"
38
#include "sysio.h"
39
 
39
 
40
/* Allow only 1 connection */
40
/* Allow only 1 connection */
41
static int client_connected = 0;
41
static int client_connected = 0;
42
 
42
 
43
#define CLRSCR   "\033[2J"
-
 
44
 
-
 
45
static void sysput(char c)
43
static void sysput(char c)
46
{
44
{
47
    __SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
45
    __SYSCALL3(SYS_IO, 1, (sysarg_t)&c, (sysarg_t) 1);
48
}
46
}
49
 
47
 
50
static void sysputs(char *s)
48
static void sysputs(char *s)
51
{
49
{
52
    __SYSCALL3(SYS_IO, 1, (sysarg_t)s, strlen(s));
50
    __SYSCALL3(SYS_IO, 1, (sysarg_t)s, strlen(s));
53
}
51
}
54
 
52
 
-
 
53
/** Send clearscreen sequence to console */
-
 
54
static void clrscr(void)
-
 
55
{
-
 
56
    sysputs("\033[2J");
-
 
57
}
-
 
58
 
-
 
59
/** Send ansi sequence to console to change cursor position */
55
static void curs_goto(unsigned int row, unsigned int col)
60
static void curs_goto(unsigned int row, unsigned int col)
56
{
61
{
57
    char control[20];
62
    char control[20];
58
 
63
 
59
    if (row > 100 || col > 100)
64
    if (row > 200 || col > 200)
60
        return;
65
        return;
61
 
66
 
62
    snprintf(control, 20, "\033[%d;%df",row, col);
67
    snprintf(control, 20, "\033[%d;%df",row, col);
63
    sysputs(control);
68
    sysputs(control);
64
}
69
}
65
 
70
 
-
 
71
/** ANSI terminal emulation main thread */
66
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
72
static void sysio_client_connection(ipc_callid_t iid, ipc_call_t *icall)
67
{
73
{
68
    int retval;
74
    int retval;
69
    ipc_callid_t callid;
75
    ipc_callid_t callid;
70
    ipc_call_t call;
76
    ipc_call_t call;
Line 104... Line 110...
104
            break;
110
            break;
105
        case FB_GET_CSIZE:
111
        case FB_GET_CSIZE:
106
            ipc_answer_fast(callid, 0, 25, 80);
112
            ipc_answer_fast(callid, 0, 25, 80);
107
            continue;
113
            continue;
108
        case FB_CLEAR:
114
        case FB_CLEAR:
109
            sysputs(CLRSCR);
115
            clrscr();
110
            retval = 0;
116
            retval = 0;
111
            break;
117
            break;
112
        default:
118
        default:
113
            retval = ENOENT;
119
            retval = ENOENT;
114
        }
120
        }
115
        ipc_answer_fast(callid,retval,0,0);
121
        ipc_answer_fast(callid,retval,0,0);
116
    }
122
    }
117
}
123
}
118
 
124
 
-
 
125
/** ANSI terminal emulation initialization */
119
void sysio_init(void)
126
void sysio_init(void)
120
{
127
{
121
    async_set_client_connection(sysio_client_connection);
128
    async_set_client_connection(sysio_client_connection);
122
    sysputs(CLRSCR);
129
    clrscr();
123
    curs_goto(0,0);
130
    curs_goto(0,0);
124
}
131
}