~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to readline.c

Tags: upstream-0.9.0+20070816
ImportĀ upstreamĀ versionĀ 0.9.0+20070816

Show diffs side-by-side

added added

removed removed

Lines of Context:
156
156
    }
157
157
}
158
158
 
 
159
static void term_backword(void)
 
160
{
 
161
    int start;
 
162
 
 
163
    if (term_cmd_buf_index == 0 || term_cmd_buf_index > term_cmd_buf_size) {
 
164
        return;
 
165
    }
 
166
 
 
167
    start = term_cmd_buf_index - 1;
 
168
 
 
169
    /* find first word (backwards) */
 
170
    while (start > 0) {
 
171
        if (!isspace(term_cmd_buf[start])) {
 
172
            break;
 
173
        }
 
174
 
 
175
        --start;
 
176
    }
 
177
 
 
178
    /* find first space (backwards) */
 
179
    while (start > 0) {
 
180
        if (isspace(term_cmd_buf[start])) {
 
181
            ++start;
 
182
            break;
 
183
        }
 
184
 
 
185
        --start;
 
186
    }
 
187
 
 
188
    /* remove word */
 
189
    if (start < term_cmd_buf_index) {
 
190
        memmove(term_cmd_buf + start,
 
191
                term_cmd_buf + term_cmd_buf_index,
 
192
                term_cmd_buf_size - term_cmd_buf_index);
 
193
        term_cmd_buf_size -= term_cmd_buf_index - start;
 
194
        term_cmd_buf_index = start;
 
195
    }
 
196
}
 
197
 
159
198
static void term_bol(void)
160
199
{
161
200
    term_cmd_buf_index = 0;
338
377
            /* NOTE: readline_start can be called here */
339
378
            term_readline_func(term_readline_opaque, term_cmd_buf);
340
379
            break;
 
380
        case 23:
 
381
            /* ^W */
 
382
            term_backword();
 
383
            break;
341
384
        case 27:
342
385
            term_esc_state = IS_ESC;
343
386
            break;