2 TerminalWx - A wxWidgets terminal widget
3 Copyright (C) 1999 Timothy Miller
5 2012-2013 Jeremy Salwen
7 License: wxWindows License Version 3.1 (See the file license3.txt)
12 #pragma implementation "gterm.hpp"
25 void GTerm::ProcessInput(int len, unsigned char *data)
27 //printf("ProcessInput called...\n");
29 StateOption *last_state;
35 //printf("ProcessInput() processing %d...\n", *input_data);
37 while (current_state[i].byte != -1 &&
38 current_state[i].byte != *input_data) i++;
40 // action must be allowed to redirect state change
41 last_state = current_state+i;
42 current_state = last_state->next_state;
43 if (last_state->action)
44 (this->*(last_state->action))();
49 if (!(mode_flags & DEFERUPDATE) ||
50 (pending_scroll > scroll_bot-scroll_top)) update_changes();
58 void GTerm::ExposeArea(int x, int y, int w, int h)
61 for (i=0; i<h; i++) changed_line(i+y, x, x+w-1);
62 if (!(mode_flags & DEFERUPDATE)) update_changes();
65 void GTerm::ResizeTerminal(int w, int h)
68 clear_area(min(width,w), 0, MAXWIDTH-1, MAXHEIGHT-1);
69 clear_area(0, min(height,h), min(width,w)-1, MAXHEIGHT-1);
72 scroll_bot = height-1;
73 if (scroll_top >= height) scroll_top = 0;
74 cx = min(width-1, cursor_x);
75 cy = min(height-1, cursor_y);
79 GTerm::GTerm(int w, int h) : width(w), height(h)
85 // could make this dynamic
86 text = new unsigned char[MAXWIDTH*MAXHEIGHT+1];
87 color = new unsigned short[MAXWIDTH*MAXHEIGHT];
89 for (i=0; i<MAXHEIGHT; i++) {
90 // make it draw whole terminal to start
92 dirty_endx[i] = MAXWIDTH-1;
96 pc_machinename = new char[7];
97 strcpy(pc_machinename, "pcterm");
113 delete[] pc_machinename;
119 GTerm::SetMachineName(char *machinename)
122 delete pc_machinename;
124 pc_machinename = new char[strlen(machinename) + 1];
125 strcpy(pc_machinename, machinename);
130 GTerm::IsSelected(int x, int y)
132 if(color && x >= 0 && x < Width() && y >= 0 && y < Height())
133 return color[(linenumbers[y] * MAXWIDTH) + x] & SELECTED;
138 GTerm::Select(int x, int y, int select)
140 if(color && x >= 0 && x < Width() && y >= 0 && y < Height())
143 color[(linenumbers[y] * MAXWIDTH) + x] |= SELECTED;
145 color[(linenumbers[y] * MAXWIDTH) + x] &= ~SELECTED;
146 changed_line(y, x, x);
152 GTerm::GetChar(int x, int y)
154 if(text && x >= 0 && x < Width() && y >= 0 && y < Height())
155 return text[(linenumbers[y] * MAXWIDTH) + x];