void GTerm::screen_align() { int y, yp, x, c; c = calc_color(7, 0, 0); for (y = 0; y<height; y++) { yp = linenumbers[y] * MAXWIDTH; int altY = m_nextLineCounter * MAXWIDTH; changed_line(y, 0, width - 1); for (x = 0; x<width; x++) { //text[yp + x] = 'E'; tm[y][x] = 'E'; //color[yp + x] = c; tm.SetColorAdjusted(y, x, c); } } }
void VTerm::screen_align() { for (u16 y = 0; y < height; y++) { u32 yp = linenumbers[y] * max_width; changed_line(y, 0, width - 1); for (u16 x = 0; x < width; x++) { text[yp + x] = 'E'; attrs[yp + x] = normal_char_attr(); } } }
void GTerm::pc_arg( void ) { int i, yp, yp2; //printf("pc_arg: pc_curcmd = %d...\n", pc_curcmd); pc_args[pc_argcount++ ] = * input_data; if (pc_argcount == pc_numargs) { switch (pc_curcmd) { case GTERM_PC_CMD_CURONOFF: //printf("pc_arg: curonoff got %d\n", *input_data); if (* input_data) clear_mode_flag(CURSORINVISIBLE); else set_mode_flag(CURSORINVISIBLE); current_state = pc_cmd_state; changed_line(cursor_y, cursor_x, cursor_x); break; case GTERM_PC_CMD_MOVECURSOR: //printf("pc_arg: movecursor (%d, %d)\n", pc_args[0], pc_args[1]); move_cursor(pc_args[0], pc_args[1]); current_state = pc_cmd_state; break; case GTERM_PC_CMD_PUTTEXT: //printf("pc_arg: puttext got %d, %d, %d, %d\n", pc_args[0], pc_args[1], pc_args[2], pc_args[3]); pc_numdata = pc_args[2] * pc_args[3] * 2; pc_datacount = 0; pc_curx = pc_args[0]; pc_cury = pc_args[1]; if (pc_numdata) current_state = pc_data_state; else current_state = pc_cmd_state; break; case GTERM_PC_CMD_WRITE: //printf("pc_arg: write got %d, %d, %d, %d\n", pc_args[0], pc_args[1], pc_args[2], pc_args[3]); pc_numdata = pc_args[2]; pc_datacount = 0; pc_curx = pc_args[0]; pc_cury = pc_args[1]; if (pc_numdata) current_state = pc_data_state; else current_state = pc_cmd_state; break; case GTERM_PC_CMD_MOVETEXT: // <sx> <sy> <wid> <len> <dx> <dy> if (pc_args[1]<pc_args[5]) { for (i = 0; i<pc_args[3]; i++) { int idx1 = pc_args[1] + i; yp = linenumbers[idx1] * MAXWIDTH; int idx2 = pc_args[5] + i; yp2 = linenumbers[idx2] * MAXWIDTH; memmove(& text[yp2 + pc_args[4]], & text[yp + pc_args[0]], pc_args[2]); string substring = tm[idx1].substr(pc_args[0], pc_args[2]); tm[idx2].replace(pc_args[4], pc_args[2], substring); memmove(& color[yp2 + pc_args[4]], & color[yp + pc_args[0]], pc_args[2]); // TODO Doesn't seem to get here in normal use, but probably ought to // eventually figure out what's going on so I can manipulate the text manager here changed_line(pc_args[5] + i, pc_args[4], pc_args[4] + pc_args[2] - 1); } } else { for (i = pc_args[3] - 1; i>=0; i--) { int idx1 = pc_args[1] + i; yp = linenumbers[idx1] * MAXWIDTH; int idx2 = pc_args[5] + i; yp2 = linenumbers[idx2] * MAXWIDTH; memmove(& text[yp2 + pc_args[4]], & text[yp + pc_args[0]], pc_args[2]); string substring = tm[idx1].substr(pc_args[0], pc_args[2]); tm[idx2].replace(pc_args[4], pc_args[2], substring); memmove(& color[yp2 + pc_args[4]], & color[yp + pc_args[0]], pc_args[2]); // TODO ditto as with previous changed_line(pc_args[5] + i, pc_args[4], pc_args[4] + pc_args[2] - 1); } } current_state = pc_cmd_state; break; case GTERM_PC_CMD_SELECTPRINTER: pc_numdata = pc_args[0]; pc_datacount = 0; memset(pc_printername, 0, sizeof(pc_printername)); if (pc_numdata) current_state = pc_data_state; else { SelectPrinter(""); current_state = pc_cmd_state; } break; case GTERM_PC_CMD_PRINTCHAR: PrintChars(1, & pc_args[0]); current_state = pc_cmd_state; break; case GTERM_PC_CMD_PRINTCHARS: pc_numdata = (pc_args[0] << 8) + pc_args[1]; pc_datacount = 0; if (pc_numdata) current_state = pc_data_state; else current_state = pc_cmd_state; break; } } }
////////////////////////////////////////////////////////////////////////////// /// private normal_input /// Handles most of the input stuff for GTerm /// /// @return void /// /// @author Timothy Miller @date 04-22-2004 ////////////////////////////////////////////////////////////////////////////// void GTerm::normal_input() { int n, n_taken, i, c, y; #if 0 char str[100]; #endif if (* input_data<32) return; if (cursor_x>=width) { if (mode_flags & NOEOLWRAP) { cursor_x = width - 1; } else { next_line(); } } n = 0; if (mode_flags & NOEOLWRAP) { while (input_data[n]>31 && n<data_len) n++; n_taken = n; if (cursor_x + n>=width) n = width - cursor_x; } else { while (input_data[n]>31 && n<data_len && cursor_x + n<width) n++; n_taken = n; } #if 0 memcpy(str, input_data, n); str[n] = 0; //printf("Processing %d characters (%d): %s\n", n, str[0], str); #endif if (mode_flags & INSERT) { changed_line(cursor_y, cursor_x, width - 1); } else { changed_line(cursor_y, cursor_x, cursor_x + n - 1); } // IMPORTANT Here's where the text pointer gets assigned. y = linenumbers[cursor_y] * MAXWIDTH; int altY = m_nextLineCounter * MAXWIDTH; // MPE: moves the text after the cursor to the right N spaces (inserting) if (mode_flags & INSERT) for (i = width - 1; i>=cursor_x + n; i--) { //text[y + i] = text[y + i - n]; char c = tm.GetCharAdjusted(cursor_y, i - n); tm.SetCharAdjusted(cursor_y, i, c); //color[y + i] = color[y + i - n]; unsigned short tempcolor = tm.GetColorAdjusted(cursor_y, i - n); tm.SetColorAdjusted(cursor_y, i, tempcolor); } c = calc_color(fg_color, bg_color, mode_flags); // MPE: inserts the new received text, overwriting what was there already for (i = 0; i<n; i++) { //text[y + cursor_x] = input_data[i]; tm.SetCharAdjusted(cursor_y, cursor_x, input_data[i]); //color[y + cursor_x] = c; tm.SetColorAdjusted(cursor_y, cursor_x, c); cursor_x++; } input_data += n_taken - 1; data_len -= n_taken - 1; }
void GTerm::pc_data( void ) { int yp; int altY; //printf("pc_data: pc_curcmd = %d, pc_datacount = %d, pc_numdata = %d, pc_curx = %d, pc_cur_y = %d...\n", pc_curcmd, pc_datacount, pc_numdata, pc_curx, pc_cury); switch (pc_curcmd) { case GTERM_PC_CMD_PUTTEXT: yp = linenumbers[pc_cury] * MAXWIDTH; altY = m_nextLineCounter * MAXWIDTH; if (!(pc_datacount & 1)) { //printf("pc_data: got char %d\n", *input_data); //text[yp + pc_curx] = * input_data; tm[pc_cury][pc_curx] = *input_data; } else { //printf("pc_data: got attr %d\n", *input_data); //color[yp + pc_curx] = * input_data << 4; tm.SetColorAdjusted(pc_cury, pc_curx, (*input_data << 4)); } if (pc_datacount & 1) { changed_line(pc_cury, pc_args[0], pc_curx); pc_curx++; if (pc_curx == pc_args[0] + pc_args[2]) { pc_curx = pc_args[0]; pc_cury++; } } break; case GTERM_PC_CMD_WRITE: yp = linenumbers[pc_cury] * MAXWIDTH; altY = m_nextLineCounter * MAXWIDTH; //text[yp + pc_curx] = * input_data; tm[pc_cury][pc_curx] = *input_data; //color[yp + pc_curx] = (unsigned short)pc_args[3] << 4; tm.SetColorAdjusted(pc_cury, pc_curx, ((unsigned short)pc_args[3] << 4) ); changed_line(pc_cury, pc_args[0], pc_curx); pc_curx++; break; case GTERM_PC_CMD_SELECTPRINTER: if (pc_datacount<GTERM_PC_MAXPRINTERNAME - 1) pc_printername[pc_datacount] = * input_data; if (pc_datacount == pc_numdata - 1) SelectPrinter(pc_printername); break; case GTERM_PC_CMD_PRINTCHARS: PrintChars(1, input_data); break; } pc_datacount++; if (pc_datacount == pc_numdata) current_state = pc_cmd_state; }