Beispiel #1
0
void console_write_char(char ch) {
	switch(ch) {
		case '\n':
			xpos = 0;
			ypos++;
			break;
		case '\t':
			xpos += 8 - (xpos % 8);
			break;
		case '\b':
			if(xpos > 0) {
				xpos -= 2;
			} else {
				if(ypos > 0) {
					xpos = xlim - 2;
					ypos--;
				}
			}
			VRAM[POS + 0] = '\0';
			VRAM[POS + 1] = color;
			break;
		default:
			VRAM[POS + 0] = ch;
			VRAM[POS + 1] = color;
			xpos += 2;
			break;
	}
	if(xpos >= xlim) {
		xpos -= xlim;
		ypos++;
	}
	console_scroll();
	console_update();
}
Beispiel #2
0
void console_down() {

    int i, j, o;

    if (cur_row == 23) {
        /* need to scroll down! */
        console_scroll_down();
        if (cur_row == 23) /* still no change */
            return;
    }

    /* move forwards: */
    o = cursor_off;

    for (j = cur_col; j < 80; j++) {
        if (screen_copy[cur_row][j])
            o++;
    }

    for (j = 0; j < 80; j++) {
        if (j >= seek_col) {
            if (!screen_copy[cur_row+1][j])
                o--;
            break;
        }
        if (screen_copy[cur_row+1][j]) {
            o++;
        }
    }

    cursor_off = o;

    console_update();

}
Beispiel #3
0
void console_init() {
    int i, j = 0;

    for (; j < 1; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x2E);
        }
    }

    for (; j < rows-1; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x1F);
        }
    }


    for (; j < rows; j++) {
        for (i = 0; i < cols; i++) {
            setCharAtOff(j, i, ' ');
            setAttrAtOff(j, i, 0x70);
        }
    }
    disable_echo();
    disable_buf();
    console_update();
}
Beispiel #4
0
void console_up() {

    int i, j, o;

    if (cur_row == 1) {
        /* need to scroll up! */
        console_scroll_up();
        if (cur_row == 1) /* still no change */
            return;
    }

    /* move backwards: */
    o = cursor_off;

    for (j = cur_col; j >= 0; j--) {
        if (screen_copy[cur_row][j])
            o--;
    }

    for (j = 79; j >= 0; j--) {
        if (screen_copy[cur_row-1][j]) {
            if (j <= seek_col) {
                break;
            }
            o--;
        }
    }

    cursor_off = o;

    console_update();

}
Beispiel #5
0
void console_insert(char c) {

    /* insert a character: */
    file_insert(c, cursor_off);
    console_update();
    console_right();

}
Beispiel #6
0
void console_backspace() {

    /* do backspace: */
    if (!cursor_off)
        return;
    file_del(cursor_off-1);
    console_update();
    console_left();
}
Beispiel #7
0
void console_left() {

    if (cursor_off == 0)
        return;

    cursor_off--;

    /* need scroll? */
    if (cursor_off < file_start) {
        console_scroll_up();
    } else {
        /* just update: */
        console_update();
    }

    seek_col = cur_col;

}
Beispiel #8
0
void console_right() {

    if (cursor_off == fileSize)
        return;

    cursor_off++;

    if (cursor_off > win_last) {
        /* need to scroll. */
        console_scroll_down();
    } else {
        /* just update: */
        console_update();
    }

    seek_col = cur_col;

}
Beispiel #9
0
void console_scroll_down() {

    int i, j, k = file_start, next_line = 0, f = 0;

    if (win_last == fileSize)
        return;

    for (j = 0; j < 80; j++) {
        char c = fileMem[k++];
        if (c == '\n')
            break;
        if (c == '\t') {
            j += 8-(j%8)-1;
            continue;
        }
    }

    file_start = k;

    console_update();

}
Beispiel #10
0
void console_scroll_up() {

    int i, last_line, count;
    int prev_line = file_start;

    if (!file_start)
        return;

    /* get the beginning of previous line: */
    while(1) {
        prev_line--;
        if (!prev_line || fileMem[prev_line-1] == '\n') {
            break;
        }
    }

    /* how many columns needed for that line? */
    i = prev_line;
    last_line = 0;
    count = 0;
    do {
        if (count % 80 == 0)
            last_line = i;
        if (fileMem[i] == '\t') {
            count += 8 - (count%8);
        } else {
            count++;
        }
    } while (++i != file_start);

    /* now we know from where to start: */
    file_start = last_line;

    /* update screen: */
    console_update();

}