Subversion Repositories HelenOS

Rev

Rev 4263 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4263 Rev 4327
Line 39... Line 39...
39
#include <console/console.h>
39
#include <console/console.h>
40
#include <proc/thread.h>
40
#include <proc/thread.h>
41
#include <arch.h>
41
#include <arch.h>
42
#include <string.h>
42
#include <string.h>
43
 
43
 
44
static indev_t srlnout;
-
 
45
 
-
 
46
indev_operations_t srlnout_ops = {
44
static indev_operations_t srln_raw_ops = {
47
    .poll = NULL
45
    .poll = NULL
48
};
46
};
49
 
47
 
50
static void ksrln(void *arg)
48
static void ksrln(void *arg)
51
{
49
{
52
    indev_t *in = (indev_t *) arg;
50
    srln_instance_t *instance = (srln_instance_t *) arg;
53
    bool cr = false;
51
    bool cr = false;
54
    uint32_t escape = 0;
52
    uint32_t escape = 0;
55
   
53
   
56
    while (true) {
54
    while (true) {
57
        wchar_t ch = _getc(in);
55
        wchar_t ch = indev_pop_character(&instance->raw);
58
       
56
       
59
        /* ANSI escape sequence processing */
57
        /* ANSI escape sequence processing */
60
        if (escape != 0) {
58
        if (escape != 0) {
61
            escape <<= 8;
59
            escape <<= 8;
62
            escape |= ch & 0xff;
60
            escape |= ch & 0xff;
Line 120... Line 118...
120
       
118
       
121
        /* Backspace */
119
        /* Backspace */
122
        if (ch == 0x7f)
120
        if (ch == 0x7f)
123
            ch = '\b';
121
            ch = '\b';
124
       
122
       
125
        indev_push_character(stdin, ch);
123
        indev_push_character(instance->sink, ch);
126
    }
124
    }
127
}
125
}
128
 
126
 
129
void srln_init(indev_t *devin)
127
srln_instance_t *srln_init(void)
130
{
128
{
-
 
129
    srln_instance_t *instance
131
    indev_initialize("srln", &srlnout, &srlnout_ops);
130
        = malloc(sizeof(srln_instance_t), FRAME_ATOMIC);
-
 
131
    if (instance) {
132
    thread_t *thread
132
        instance->thread
133
        = thread_create(ksrln, devin, TASK, 0, "ksrln", false);
133
            = thread_create(ksrln, (void *) instance, TASK, 0, "ksrln", false);
134
   
134
       
135
    if (thread) {
135
        if (!instance->thread) {
136
        stdin = &srlnout;
136
            free(instance);
-
 
137
            return NULL;
-
 
138
        }
-
 
139
       
137
        thread_ready(thread);
140
        instance->sink = NULL;
-
 
141
        indev_initialize("srln", &instance->raw, &srln_raw_ops);
138
    }
142
    }
-
 
143
   
-
 
144
    return instance;
-
 
145
}
-
 
146
 
-
 
147
indev_t *srln_wire(srln_instance_t *instance, indev_t *sink)
-
 
148
{
-
 
149
    ASSERT(instance);
-
 
150
    ASSERT(sink);
-
 
151
   
-
 
152
    instance->sink = sink;
-
 
153
    thread_ready(instance->thread);
-
 
154
   
-
 
155
    return &instance->raw;
139
}
156
}
140
 
157
 
141
/** @}
158
/** @}
142
 */
159
 */