Esempio n. 1
0
bool read_command()
{
	if (scanf("%s", cmd) != 1 || cmd[0] != '.') return false;
	if (cmd[1] == 'E') { do_eop(); return true; }

	char font;
	int row, col;
	scanf(" %*c%c %d", &font, &row);
	if (cmd[1] == 'P') scanf("%d", &col);
	scanf(" |%[^|]|", str);

	int width = (font == '1' ? 1 : 6) * strlen(str);
	if      (cmd[1] == 'L') col = 1;
	else if (cmd[1] == 'R') col = 61 - width;
	else if (cmd[1] == 'C') col = 31 - width/2;

	if      (font == '1') do_font1(row-1, col-1);
	else if (font == '5') do_font5(row-1, col-1);

	return true;
}
Esempio n. 2
0
int vt_putch(struct vt_file *f, int c)
{
	struct vt *vtptr;
	if (!initialized) return -1;
	if (!f || !(vtptr = f->vtptr)) return -1;
	if (is_threading()) {
		spinl_lock(&vtptr->writelock);
	}

	if (vtptr->scroll != 0) {
		vtptr->scroll = 0;
		vt_scroll(0);
	}

	if (0) {}
	else if (c >= ' ') { /* printable character */
		vt_scroll_if_needed(f);
		if (vtptr->index == cur_vt) {
			if(driverstream){
				char cc[2];
				cc[0] = c;
				cc[1] = f->color;
				fwrite(cc, 1, 2, driverstream);
			}
			else{
				*(char*)(0xB8000 + vtptr->cy * 160 + vtptr->cx * 2) = c;
				*(char*)(0xB8000 + vtptr->cy * 160 + vtptr->cx * 2 + 1) = 0x7;
			}
		}
		if(vtptr->buffer && initialized) {
			*(vtptr->buffer + vtptr->bufsize - (driverinfo.h*driverinfo.w*2) + vtptr->cy * (driverinfo.w*2) + vtptr->cx * 2) = c;
			*(vtptr->buffer + vtptr->bufsize - (driverinfo.h*driverinfo.w*2) + vtptr->cy * (driverinfo.w*2) + vtptr->cx * 2 + 1) = f->color;
		}
		vtptr->cx++;
	}
	else if (c == '\n') { /* new line */
		vtptr->cx = 0;
		vt_scroll_if_needed(f);
		vtptr->cy++;
		vt_update_cursor();
	}
	else if (c == '\r') { /* return */
		vtptr->cx = 0;
		vt_update_cursor();
	}
	else if (c == '\t') { /* tab */
		vtptr->cx = (vtptr->cx + 8) & ~7;
		vt_update_cursor();
	}
	else if (c == '\b') { /* backspace */
		if (vtptr->cx > 0) {
			vtptr->cx--;
		} else {
			vtptr->cx = (driverinfo.w) - 1;
			vtptr->cy--;
		}
		vt_update_cursor();
	}

	if (driverstream) {
		if (vtptr->cx >= (driverinfo.w)) {
			vtptr->cx = 0;
			vtptr->cy++;
		}
	}
	else {
		if (vtptr->cx >= 80) {
			vtptr->cx = 0;
			vtptr->cy++;
		}
	}

	if (is_threading()) {
		spinl_unlock(&vtptr->writelock);
	}
	do_eop();
	return 0;
}