Each virtual window gets its own virtual print cursor

This commit is contained in:
Markus Gans 2016-10-15 03:32:30 +02:00
parent e6368749d4
commit ff6deaf4ab
7 changed files with 304 additions and 290 deletions

View File

@ -1,3 +1,6 @@
2016-10-15 Markus Gans <guru.mail@muenster.de>
* Each virtual window gets its own virtual print cursor
2016-10-14 Markus Gans <guru.mail@muenster.de> 2016-10-14 Markus Gans <guru.mail@muenster.de>
* Virtual windows can now store their own offset information * Virtual windows can now store their own offset information
* Correct implementation of the move() method * Correct implementation of the move() method

View File

@ -139,53 +139,53 @@ Class digramm
: ├────┤ FButton ├-----------------------------┐ : ├────┤ FButton ├-----------------------------┐
: │ └─────────┘ : : │ └─────────┘ :
: │ ┌────────┐1 : : │ ┌────────┐1 :
: ├────┤ FLabel ├------------------------------: : ├────┤ FLabel ├------------------------------
: │ └────────┘ : : │ └────────┘ :
: │ ┌───────────┐1 : : │ ┌───────────┐1 :
: ├────┤ FLineEdit ├---------------------------: : ├────┤ FLineEdit ├---------------------------
: │ └───────────┘ : : │ └───────────┘ :
: │ ┌──────────────┐ ┌──────────────┐1 : : │ ┌──────────────┐ ┌──────────────┐1 :
:1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton ├--: :1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton ├--
┌─────────┐ ┌─────┴───┐ │ └──────────────┘ │ └──────────────┘ : ┌─────────┐ ┌────────┐ ┌─────┴───┐ │ └──────────────┘ │ └──────────────┘ :
│ FObject │◄─┬┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐1 : │ FObject │◄─┬─┤ FVTerm │◄───┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐1 :
└─────────┘ │└───┬─┬───┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----: └─────────┘ │ └────┬───┘ └───┬─┬───┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----
│ :1:1 │ └───────────────┘ │ └───────────┘ : :1 :1:1 │ └───────────────┘ │ └───────────┘ :
┌───────┐ │ : : │ ┌──────────────┐ │ ┌─────────┐1 : ┌───────┐ │ : : : │ ┌──────────────┐ │ ┌─────────┐1 :
│ FTerm │◄─┘ : : ├────┤ FProgressbar │ └──┤ FSwitch ├-------: │ FTerm │◄─┘ └------------┐ : ├────┤ FProgressbar │ └──┤ FSwitch ├-------┐
┬─┬─┬──┘ : : │ └──────────────┘ └─────────┘ : ─┬───┬─┘ : : │ └──────────────┘ └─────────┘ :
:1:1:1 : : │ ┌────────────┐ : *┌─────────┐ :1 :1 : : │ ┌────────────┐ : *┌─────────┐
: : └----------┤ : ├────┤ FScrollbar │ ├---┤ FString │ : └------------------------┐ : ├────┤ FScrollbar │ ├---┤ FString │
: :1 : : │ └────────────┘ : └─────────┘ : : : │ └────────────┘ : └─────────┘
:┌┴──────────┐ : : │ ┌───────────┐1 : : 1┌───────────┐ : : │ ┌───────────┐1 :
:│ FOptiAttr │ : : ├────┤ FTextView ├---------------------------: └---┤ FOptiAttr │ : : ├────┤ FTextView ├---------------------------┘
:└───────────┘ : : │ └───────────┘ : : └───────────┘ : : │ └───────────┘ :
:1 : : │ ┌──────────┐1 *┌──────────────┐1 : : 1┌───────────┐ : : │ ┌──────────┐1 *┌──────────────┐1 :
┌┴──────────┐ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----: └---┤ FOptiMove │ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----┘
│ FOptiMove │ : : │ └──────────┘ └──────────────┘ : └───────────┘ : : │ └──────────┘ └──────────────┘ :
└───────────┘ : : │ ┌────────────┐1 *┌────────────┐1 : : : │ ┌────────────┐1 *┌────────────┐1 :
: : ├────┤ FStatusBar ├-----┤ FStatusKey ├-------: : : │ ┌──┤ FStatusBar ├-----┤ FStatusKey ├-------┘
: : │ └────┬───────┘ └────────────┘ : : : │ │ └────┬───────┘ └────────────┘ :
: : │ 1└----------------------------------: : : │ │ 1└----------------------------------┘
: : │ ┌─────────────┐1 : : : │ ▼ ┌─────────────┐1 :
: : ┌───┴─────┐ ┌─────────┐ ┌──┤ FFileDialog ├----: : : ┌───┴─┴───┐ ┌─────────┐ ┌──┤ FFileDialog ├----┘
: : │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ : : : │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ :
: : └──┬──┬───┘ └────┬────┘ │ ┌─────────────┐1 : : : └──┬──┬───┘ └────┬────┘ │ ┌─────────────┐1 :
: : ▲ ▲ 1: └──┤ FMessageBox ├----: : : ▲ ▲ 1: └──┤ FMessageBox ├----
: : │ │ : └─────────────┘ : : : │ │ : └─────────────┘ :
: : │ │ └------------------------------: : : │ │ └------------------------------
: : │ │ ┌──────────┐ : : : │ │ ┌──────────┐ :
: : │ └──────┤ FToolTip │ : : : │ └──────┤ FToolTip ├------------------------┘
: : │ └──────────┘ : : : │ └──────────┘ :
: : └───────────────┐ ┌──────────┐ : : : └───────────────┐ ┌──────────┐ :
: : │ ┌───┤ FMenuBar │ : : : │ ┌───┤ FMenuBar │ :
: : ┌───────────┐ └──────┤ └──────────┘ : : : ┌───────────┐ └──────┤ └──────────┘ :
: : │ FMenuList │◄──────────┤ ┌───────┐ : : : │ FMenuList │◄──────────┤ ┌───────┐ :
: : └────┬──────┘ └───┤ FMenu │◄──┐ : : : └────┬──────┘ └───┤ FMenu │◄──┐ :
: : : └───────┘ │ : : : 1: └───────┘ │ :
: : : ┌─────────────────┐ │ : : : : ┌─────────────────┐ │ :
: : : │ FDialogListMenu ├───┘ : : : : │ FDialogListMenu ├───┘ :
: : : └─────────────────┘ : : : : └─────────────────┘ :
: : 1: ┌────────────────┐* : : : : ┌────────────────┐* :
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ : : : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : : : : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
: : : └───────────┘ │ ┌────────────────┐*: : : : : └───────────┘ │ ┌────────────────┐*: :
@ -194,7 +194,7 @@ Class digramm
: : └---------------------------------------┘ : : : └---------------------------------------┘ :
: └---------------------------------------------------┘ : └---------------------------------------------------┘
: *┌────────┐ : *┌────────┐
---┤ FPoint │ ---┤ FPoint │
: └────────┘ : └────────┘
: *┌───────┐ : *┌───────┐
└---┤ FRect │ └---┤ FRect │

View File

@ -40,53 +40,53 @@
: ├────┤ FButton ├-----------------------------┐ : ├────┤ FButton ├-----------------------------┐
: │ └─────────┘ : : │ └─────────┘ :
: │ ┌────────┐1 : : │ ┌────────┐1 :
: ├────┤ FLabel ├------------------------------: : ├────┤ FLabel ├------------------------------
: │ └────────┘ : : │ └────────┘ :
: │ ┌───────────┐1 : : │ ┌───────────┐1 :
: ├────┤ FLineEdit ├---------------------------: : ├────┤ FLineEdit ├---------------------------
: │ └───────────┘ : : │ └───────────┘ :
: │ ┌──────────────┐ ┌──────────────┐1 : : │ ┌──────────────┐ ┌──────────────┐1 :
:1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton ├--: :1 ├────┤ FButtonGroup │ ┌──┤ FRadioButton ├--
┌─────────┐ ┌─────┴───┐ │ └──────────────┘ │ └──────────────┘ : ┌─────────┐ ┌────────┐ ┌─────┴───┐ │ └──────────────┘ │ └──────────────┘ :
│ FObject │◄─┬┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐1 : │ FObject │◄─┬─┤ FVTerm │◄───┤ FWidget │◄─┤ ┌───────────────┐ │ ┌───────────┐1 :
└─────────┘ │└───┬─┬───┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----: └─────────┘ │ └────┬───┘ └───┬─┬───┘ ├────┤ FToggleButton │◄─┼──┤ FCheckBox ├-----
│ :1:1 │ └───────────────┘ │ └───────────┘ : :1 :1:1 │ └───────────────┘ │ └───────────┘ :
┌───────┐ │ : : │ ┌──────────────┐ │ ┌─────────┐1 : ┌───────┐ │ : : : │ ┌──────────────┐ │ ┌─────────┐1 :
│ FTerm │◄─┘ : : ├────┤ FProgressbar │ └──┤ FSwitch ├-------: │ FTerm │◄─┘ └------------┐ : ├────┤ FProgressbar │ └──┤ FSwitch ├-------┐
┬─┬─┬──┘ : : │ └──────────────┘ └─────────┘ : ─┬───┬─┘ : : │ └──────────────┘ └─────────┘ :
:1:1:1 : : │ ┌────────────┐ : *┌─────────┐ :1 :1 : : │ ┌────────────┐ : *┌─────────┐
: : └----------┤ : ├────┤ FScrollbar │ ├---┤ FString │ : └------------------------┐ : ├────┤ FScrollbar │ ├---┤ FString │
: :1 : : │ └────────────┘ : └─────────┘ : : : │ └────────────┘ : └─────────┘
:┌┴──────────┐ : : │ ┌───────────┐1 : : 1┌───────────┐ : : │ ┌───────────┐1 :
:│ FOptiAttr │ : : ├────┤ FTextView ├---------------------------: └---┤ FOptiAttr │ : : ├────┤ FTextView ├---------------------------┘
:└───────────┘ : : │ └───────────┘ : : └───────────┘ : : │ └───────────┘ :
:1 : : │ ┌──────────┐1 *┌──────────────┐1 : : 1┌───────────┐ : : │ ┌──────────┐1 *┌──────────────┐1 :
┌┴──────────┐ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----: └---┤ FOptiMove │ : : ├────┤ FListBox ├-------┤ FListBoxItem ├-----┘
│ FOptiMove │ : : │ └──────────┘ └──────────────┘ : └───────────┘ : : │ └──────────┘ └──────────────┘ :
└───────────┘ : : │ ┌────────────┐1 *┌────────────┐1 : : : │ ┌────────────┐1 *┌────────────┐1 :
: : ├────┤ FStatusBar ├-----┤ FStatusKey ├-------: : : │ ┌──┤ FStatusBar ├-----┤ FStatusKey ├-------┘
: : │ └────┬───────┘ └────────────┘ : : : │ │ └────┬───────┘ └────────────┘ :
: : │ 1└----------------------------------: : : │ │ 1└----------------------------------┘
: : │ ┌─────────────┐1 : : : │ ▼ ┌─────────────┐1 :
: : ┌───┴─────┐ ┌─────────┐ ┌──┤ FFileDialog ├----: : : ┌───┴─┴───┐ ┌─────────┐ ┌──┤ FFileDialog ├----┘
: : │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ : : : │ FWindow │◄─┤ FDialog │◄──┤ └─────────────┘ :
: : └──┬──┬───┘ └────┬────┘ │ ┌─────────────┐1 : : : └──┬──┬───┘ └────┬────┘ │ ┌─────────────┐1 :
: : ▲ ▲ 1: └──┤ FMessageBox ├----: : : ▲ ▲ 1: └──┤ FMessageBox ├----
: : │ │ : └─────────────┘ : : : │ │ : └─────────────┘ :
: : │ │ └------------------------------: : : │ │ └------------------------------
: : │ │ ┌──────────┐ : : : │ │ ┌──────────┐ :
: : │ └──────┤ FToolTip │ : : : │ └──────┤ FToolTip ├------------------------┘
: : │ └──────────┘ : : : │ └──────────┘ :
: : └───────────────┐ ┌──────────┐ : : : └───────────────┐ ┌──────────┐ :
: : │ ┌───┤ FMenuBar │ : : : │ ┌───┤ FMenuBar │ :
: : ┌───────────┐ └──────┤ └──────────┘ : : : ┌───────────┐ └──────┤ └──────────┘ :
: : │ FMenuList │◄──────────┤ ┌───────┐ : : : │ FMenuList │◄──────────┤ ┌───────┐ :
: : └────┬──────┘ └───┤ FMenu │◄──┐ : : : └────┬──────┘ └───┤ FMenu │◄──┐ :
: : : └───────┘ │ : : : 1: └───────┘ │ :
: : : ┌─────────────────┐ │ : : : : ┌─────────────────┐ │ :
: : : │ FDialogListMenu ├───┘ : : : : │ FDialogListMenu ├───┘ :
: : : └─────────────────┘ : : : : └─────────────────┘ :
: : 1: ┌────────────────┐* : : : : ┌────────────────┐* :
: : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ : : : : *┌───────────┐ ┌──┤ FCheckMenuItem ├-┐ :
: : ├--┤ FMenuItem │◄─┤ └────────────────┘ : : : : ├--┤ FMenuItem │◄─┤ └────────────────┘ : :
: : : └───────────┘ │ ┌────────────────┐*: : : : : └───────────┘ │ ┌────────────────┐*: :
@ -95,7 +95,7 @@
: : └---------------------------------------┘ : : : └---------------------------------------┘ :
: └---------------------------------------------------┘ : └---------------------------------------------------┘
: *┌────────┐ : *┌────────┐
---┤ FPoint │ ---┤ FPoint │
: └────────┘ : └────────┘
: *┌───────┐ : *┌───────┐
└---┤ FRect │ └---┤ FRect │

View File

@ -19,7 +19,6 @@ bool FVTerm::vterm_updates;
int FVTerm::skipped_terminal_update = 0; int FVTerm::skipped_terminal_update = 0;
std::queue<int>* FVTerm::output_buffer = 0; std::queue<int>* FVTerm::output_buffer = 0;
FPoint* FVTerm::term_pos = 0; FPoint* FVTerm::term_pos = 0;
FPoint* FVTerm::cursor = 0;
FVTerm::term_area* FVTerm::vterm = 0; FVTerm::term_area* FVTerm::vterm = 0;
FVTerm::term_area* FVTerm::vdesktop = 0; FVTerm::term_area* FVTerm::vdesktop = 0;
FVTerm::term_area* FVTerm::last_area = 0; FVTerm::term_area* FVTerm::last_area = 0;
@ -66,7 +65,6 @@ void FVTerm::init()
vdesktop = 0; vdesktop = 0;
last_area = 0; last_area = 0;
term_pos = new FPoint(-1,-1); term_pos = new FPoint(-1,-1);
cursor = new FPoint(0,0);
output_buffer = new std::queue<int>; output_buffer = new std::queue<int>;
// Preset to false // Preset to false
@ -129,9 +127,6 @@ void FVTerm::finish()
removeArea (vdesktop); removeArea (vdesktop);
removeArea (vterm); removeArea (vterm);
if ( cursor )
delete cursor;
if ( term_pos ) if ( term_pos )
delete term_pos; delete term_pos;
} }
@ -192,6 +187,8 @@ void FVTerm::createArea ( int x_offset, int y_offset
area->height = -1; area->height = -1;
area->right_shadow = 0; area->right_shadow = 0;
area->bottom_shadow = 0; area->bottom_shadow = 0;
area->cursor_x = 0;
area->cursor_y = 0;
area->input_cursor_x = -1; area->input_cursor_x = -1;
area->input_cursor_y = -1; area->input_cursor_y = -1;
area->input_cursor_visible = false; area->input_cursor_visible = false;
@ -369,15 +366,15 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
iter = widget->window_list->begin(); iter = widget->window_list->begin();
end = widget->window_list->end(); end = widget->window_list->end();
while ( iter != end ) for (; iter != end; ++iter)
{ {
term_area* win = (*iter)->getVWin(); term_area* win = (*iter)->getVWin();
if ( ! win ) if ( ! win )
break; continue;
if ( ! win->visible ) if ( ! win->visible )
break; continue;
int win_x = win->x_offset; int win_x = win->x_offset;
int win_y = win->y_offset; int win_y = win->y_offset;
@ -424,8 +421,6 @@ void FVTerm::restoreVTerm (int x, int y, int w, int h)
sc = tmp; sc = tmp;
} }
} }
++iter;
} }
} }
@ -469,15 +464,15 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
iter = w->window_list->begin(); iter = w->window_list->begin();
end = w->window_list->end(); end = w->window_list->end();
while ( iter != end ) for (; iter != end; ++iter)
{ {
term_area* win = (*iter)->getVWin(); term_area* win = (*iter)->getVWin();
if ( ! win ) if ( ! win )
break; continue;
if ( ! win->visible ) if ( ! win->visible )
break; continue;
int win_x = win->x_offset; int win_x = win->x_offset;
int win_y = win->y_offset; int win_y = win->y_offset;
@ -505,8 +500,6 @@ FVTerm::covered_state FVTerm::isCovered ( int x, int y
if ( area == win ) if ( area == win )
found = true; found = true;
++iter;
} }
} }
@ -700,8 +693,8 @@ bool FVTerm::updateVTermCursor (FVTerm::term_area* area)
{ {
int cx, cy, ax, ay, x, y; int cx, cy, ax, ay, x, y;
// area offset // area offset
ax = area->widget->getTermX() - 1; ax = area->x_offset;
ay = area->widget->getTermY() - 1; ay = area->y_offset;
// area cursor position // area cursor position
cx = area->input_cursor_x; cx = area->input_cursor_x;
cy = area->input_cursor_y; cy = area->input_cursor_y;
@ -829,8 +822,8 @@ void FVTerm::getArea (int x, int y, int w, int h, FVTerm::term_area* area)
if ( ! area ) if ( ! area )
return; return;
dx = x - area->widget->getTermX(); dx = x - area->x_offset + 1;
dy = y - area->widget->getTermY(); dy = y - area->y_offset + 1;
if ( x < 0 || y < 0 ) if ( x < 0 || y < 0 )
return; return;
@ -990,6 +983,7 @@ void FVTerm::putArea (int ax, int ay, FVTerm::term_area* area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::scrollAreaForward (FVTerm::term_area* area) void FVTerm::scrollAreaForward (FVTerm::term_area* area)
{ {
// Scrolls the entire area up line down
int total_width; int total_width;
int length; int length;
int y_max; int y_max;
@ -1032,6 +1026,7 @@ void FVTerm::scrollAreaForward (FVTerm::term_area* area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::scrollAreaReverse (FVTerm::term_area* area) void FVTerm::scrollAreaReverse (FVTerm::term_area* area)
{ {
// Scrolls the entire area one line down
int total_width; int total_width;
int length; int length;
FOptiAttr::char_data nc; // next character FOptiAttr::char_data nc; // next character
@ -1072,11 +1067,12 @@ void FVTerm::scrollAreaReverse (FVTerm::term_area* area)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::clearArea (FVTerm::term_area* area) void FVTerm::clearArea (FVTerm::term_area* area)
{ {
// clear the area with the current attributes
FOptiAttr::char_data nc; // next character FOptiAttr::char_data nc; // next character
int total_width; int total_width;
uInt w; uInt w;
// clear with the current attributes and space characters // current attributes with a space character
std::memcpy (&nc, &next_attribute, sizeof(FOptiAttr::char_data)); std::memcpy (&nc, &next_attribute, sizeof(FOptiAttr::char_data));
nc.code = ' '; nc.code = ' ';
@ -1142,6 +1138,7 @@ FOptiAttr::char_data FVTerm::getCharacter ( character_type type
, const FPoint& pos , const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
// Gets the overlapped or the covered character for a given position
return getCharacter (type, pos.getX(), pos.getY(), obj); return getCharacter (type, pos.getX(), pos.getY(), obj);
} }
@ -1151,8 +1148,8 @@ FOptiAttr::char_data FVTerm::getCharacter ( character_type char_type
, int y , int y
, FVTerm* obj ) , FVTerm* obj )
{ {
// get the overlapped or the covered character for a position // Gets the overlapped or the covered character for the position (x,y)
int xx,yy; int xx, yy;
FOptiAttr::char_data* cc; // covered character FOptiAttr::char_data* cc; // covered character
FOptiAttr::char_data s_ch; // shadow character FOptiAttr::char_data s_ch; // shadow character
FOptiAttr::char_data i_ch; // inherit background character FOptiAttr::char_data i_ch; // inherit background character
@ -1186,7 +1183,7 @@ FOptiAttr::char_data FVTerm::getCharacter ( character_type char_type
iter = w->window_list->begin(); iter = w->window_list->begin();
end = w->window_list->end(); end = w->window_list->end();
while ( iter != end ) for (; iter != end; ++iter)
{ {
bool significant_char; bool significant_char;
@ -1202,10 +1199,10 @@ FOptiAttr::char_data FVTerm::getCharacter ( character_type char_type
term_area* win = (*iter)->getVWin(); term_area* win = (*iter)->getVWin();
if ( ! win ) if ( ! win )
break; continue;
if ( ! win->visible ) if ( ! win->visible )
break; continue;
int win_x = win->x_offset; int win_x = win->x_offset;
int win_y = win->y_offset; int win_y = win->y_offset;
@ -1248,27 +1245,35 @@ FOptiAttr::char_data FVTerm::getCharacter ( character_type char_type
} }
else if ( char_type == covered_character ) else if ( char_type == covered_character )
break; break;
++iter;
} }
} }
return *cc; return *cc;
} }
//----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getCoveredCharacter ( const FPoint& pos
, FVTerm* obj )
{
// Gets the covered character for a given position
return getCharacter (covered_character, pos.getX(), pos.getY(), obj);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getCoveredCharacter ( int x FOptiAttr::char_data FVTerm::getCoveredCharacter ( int x
, int y , int y
, FVTerm* obj) , FVTerm* obj)
{ {
// Gets the covered character for the position (x,y)
return getCharacter (covered_character, x, y, obj); return getCharacter (covered_character, x, y, obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getCoveredCharacter ( const FPoint& pos FOptiAttr::char_data FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj ) , FVTerm* obj )
{ {
return getCharacter (covered_character, pos.getX(), pos.getY(), obj); // Gets the overlapped character for a given position
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1276,32 +1281,28 @@ FOptiAttr::char_data FVTerm::getOverlappedCharacter ( int x
, int y , int y
, FVTerm* obj) , FVTerm* obj)
{ {
// Gets the overlapped character for the position (x,y)
return getCharacter (overlapped_character, x, y, obj); return getCharacter (overlapped_character, x, y, obj);
} }
//----------------------------------------------------------------------
FOptiAttr::char_data FVTerm::getOverlappedCharacter ( const FPoint& pos
, FVTerm* obj )
{
return getCharacter (overlapped_character, pos.getX(), pos.getY(), obj);
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::startTerminalUpdate() void FVTerm::startTerminalUpdate()
{ {
// Pauses the terminal updates for the printing phase
terminal_update_complete = false; terminal_update_complete = false;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::finishTerminalUpdate() void FVTerm::finishTerminalUpdate()
{ {
// After the printing phase is completed, the terminal will be updated
terminal_update_complete = true; terminal_update_complete = true;
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::setTermXY (register int x, register int y) void FVTerm::setTermXY (register int x, register int y)
{ {
// sets the hardware cursor to the given (x,y) position // Sets the hardware cursor to the given (x,y) position
int term_x, term_y, term_width, term_height; int term_x, term_y, term_width, term_height;
char* move_str; char* move_str;
@ -1338,6 +1339,7 @@ void FVTerm::setTermXY (register int x, register int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::hideCursor (bool on) bool FVTerm::hideCursor (bool on)
{ {
// Hides or shows the input cursor on the terminal
if ( on == hidden_cursor ) if ( on == hidden_cursor )
return hidden_cursor; return hidden_cursor;
@ -1420,6 +1422,7 @@ void FVTerm::updateTerminal (bool on)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::updateTerminal() void FVTerm::updateTerminal()
{ {
// Updates pending changes to the terminal
term_area* vt; term_area* vt;
int term_width, term_height; int term_width, term_height;
@ -1501,7 +1504,7 @@ void FVTerm::updateTerminal()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FVTerm::updateTerminalCursor() bool FVTerm::updateTerminalCursor()
{ {
// updates the input cursor visibility and the position // Updates the input cursor visibility and the position
if ( vterm && vterm->input_cursor_visible ) if ( vterm && vterm->input_cursor_visible )
{ {
int x = vterm->input_cursor_x; int x = vterm->input_cursor_x;
@ -1523,6 +1526,7 @@ bool FVTerm::updateTerminalCursor()
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::processTerminalUpdate() void FVTerm::processTerminalUpdate()
{ {
// Retains terminal updates if there are unprocessed inputs
const int max_skip = 8; const int max_skip = 8;
if ( terminal_update_pending ) if ( terminal_update_pending )
@ -1559,9 +1563,27 @@ bool FVTerm::isInsideTerminal (int x, int y)
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FPoint* FVTerm::getPrintPos() const void FVTerm::setPrintCursor (register int x, register int y)
{ {
return cursor; term_area* win = getPrintArea();
if ( win )
{
win->cursor_x = x - win->x_offset;
win->cursor_y = y - win->y_offset;
}
}
//----------------------------------------------------------------------
FPoint FVTerm::getPrintCursor()
{
term_area* win = getPrintArea();
if ( win )
return FPoint ( win->x_offset + win->cursor_x
, win->y_offset + win->cursor_y );
return FPoint(0,0);
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
@ -1707,9 +1729,7 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
{ {
while ( *p ) while ( *p )
{ {
int x_offset, y_offset, width, height, rsh, bsh; int width, height, rsh, bsh;
x_offset = area->x_offset;
y_offset = area->y_offset;
width = area->width; width = area->width;
height = area->height; height = area->height;
rsh = area->right_shadow; rsh = area->right_shadow;
@ -1718,22 +1738,22 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
switch ( *p ) switch ( *p )
{ {
case '\n': case '\n':
cursor->y_ref()++; area->cursor_y++;
case '\r': case '\r':
cursor->x_ref() = 1; area->cursor_x = 1;
break; break;
case '\t': case '\t':
cursor->x_ref() = short ( uInt(cursor->x_ref()) area->cursor_x = short ( uInt(area->cursor_x)
+ tabstop + tabstop
- uInt(cursor->x_ref()) - uInt(area->cursor_x)
+ 1 + 1
% tabstop ); % tabstop );
break; break;
case '\b': case '\b':
cursor->x_ref()--; area->cursor_x--;
break; break;
case '\a': case '\a':
@ -1742,8 +1762,8 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
default: default:
{ {
short x = short(cursor->getX() - 1); int ax = area->cursor_x - 1;
short y = short(cursor->getY() - 1); int ay = area->cursor_y - 1;
FOptiAttr::char_data nc; // next character FOptiAttr::char_data nc; // next character
nc.code = *p; nc.code = *p;
@ -1766,9 +1786,6 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
nc.trans_shadow = next_attribute.trans_shadow; nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg; nc.inherit_bg = next_attribute.inherit_bg;
int ax = x - x_offset;
int ay = y - y_offset;
if ( area if ( area
&& ax >= 0 && ay >= 0 && ax >= 0 && ay >= 0
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
@ -1806,19 +1823,19 @@ int FVTerm::print (FVTerm::term_area* area, FString& s)
} }
} }
cursor->x_ref()++; area->cursor_x++;
} }
} }
if ( cursor->x_ref() > x_offset + width + rsh ) if ( area->cursor_x > width + rsh )
{ {
cursor->x_ref() = short(x_offset + 1); area->cursor_x = 1;
cursor->y_ref()++; area->cursor_y++;
} }
if ( cursor->y_ref() > y_offset + height + bsh ) if ( area->cursor_y > height + bsh )
{ {
cursor->y_ref()--; area->cursor_y--;
break; break;
} }
@ -1852,18 +1869,17 @@ int FVTerm::print (register int c)
int FVTerm::print (FVTerm::term_area* area, register int c) int FVTerm::print (FVTerm::term_area* area, register int c)
{ {
FOptiAttr::char_data nc; // next character FOptiAttr::char_data nc; // next character
int x_offset, y_offset, width, height, rsh, bsh, ax, ay; int width, height, rsh, bsh, ax, ay;
short x, y;
if ( ! area ) if ( ! area )
return -1; return -1;
x_offset = area->x_offset;
y_offset = area->y_offset;
width = area->width; width = area->width;
height = area->height; height = area->height;
rsh = area->right_shadow; rsh = area->right_shadow;
bsh = area->bottom_shadow; bsh = area->bottom_shadow;
ax = area->cursor_x - 1;
ay = area->cursor_y - 1;
nc.code = c; nc.code = c;
nc.fg_color = next_attribute.fg_color; nc.fg_color = next_attribute.fg_color;
@ -1885,11 +1901,6 @@ int FVTerm::print (FVTerm::term_area* area, register int c)
nc.trans_shadow = next_attribute.trans_shadow; nc.trans_shadow = next_attribute.trans_shadow;
nc.inherit_bg = next_attribute.inherit_bg; nc.inherit_bg = next_attribute.inherit_bg;
x = short(cursor->getX() - 1);
y = short(cursor->getY() - 1);
ax = x - x_offset;
ay = y - y_offset;
if ( ax >= 0 && ay >= 0 if ( ax >= 0 && ay >= 0
&& ax < area->width + area->right_shadow && ax < area->width + area->right_shadow
&& ay < area->height + area->bottom_shadow ) && ay < area->height + area->bottom_shadow )
@ -1927,17 +1938,17 @@ int FVTerm::print (FVTerm::term_area* area, register int c)
} }
} }
cursor->x_ref()++; area->cursor_x++;
if ( cursor->x_ref() > x_offset + width + rsh ) if ( area->cursor_x > width + rsh )
{ {
cursor->x_ref() = short(x_offset + 1); area->cursor_x = 1;
cursor->y_ref()++; area->cursor_y++;
} }
if ( cursor->y_ref() > y_offset + height + bsh ) if ( area->cursor_y > height + bsh )
{ {
cursor->y_ref()--; area->cursor_y--;
updateVTerm (area); updateVTerm (area);
return -1; return -1;
} }

View File

@ -50,7 +50,6 @@ class FVTerm : public FObject, public FTerm
static FOptiAttr::char_data term_attribute; static FOptiAttr::char_data term_attribute;
static FOptiAttr::char_data next_attribute; static FOptiAttr::char_data next_attribute;
static FPoint* term_pos; // terminal cursor position static FPoint* term_pos; // terminal cursor position
static FPoint* cursor; // virtual print cursor
static FTermcap::tcap_map* tcap; static FTermcap::tcap_map* tcap;
static bool hidden_cursor; static bool hidden_cursor;
@ -90,6 +89,8 @@ class FVTerm : public FObject, public FTerm
int height; int height;
int right_shadow; int right_shadow;
int bottom_shadow; int bottom_shadow;
int cursor_x;
int cursor_y;
int input_cursor_x; int input_cursor_x;
int input_cursor_y; int input_cursor_y;
int input_cursor_visible; int input_cursor_visible;
@ -182,7 +183,8 @@ class FVTerm : public FObject, public FTerm
void setPrintCursor (const FPoint&); void setPrintCursor (const FPoint&);
void setPrintCursor (register int, register int); void setPrintCursor (register int, register int);
FPoint* getPrintPos() const; FPoint getPrintCursor();
int printf (const wchar_t*, ...); int printf (const wchar_t*, ...);
int printf (const char*, ...) int printf (const char*, ...)
#if defined(__clang__) #if defined(__clang__)
@ -336,10 +338,6 @@ inline FVTerm::term_area* FVTerm::getVWin() const
inline void FVTerm::setPrintCursor (const FPoint& pos) inline void FVTerm::setPrintCursor (const FPoint& pos)
{ setPrintCursor (pos.getX(), pos.getY()); } { setPrintCursor (pos.getX(), pos.getY()); }
//----------------------------------------------------------------------
inline void FVTerm::setPrintCursor (register int x, register int y)
{ cursor->setPoint(x,y); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setColor (register short fg, register short bg) inline void FVTerm::setColor (register short fg, register short bg)
{ {

View File

@ -1867,6 +1867,7 @@ void FWidget::move (int dx, int dy)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
bool FWidget::setCursorPos (register int x, register int y) bool FWidget::setCursorPos (register int x, register int y)
{ {
// sets the input cursor position
widget_cursor_position.setPoint(x,y); widget_cursor_position.setPoint(x,y);
if ( (flags & fc::focus) != 0 && ! isWindowWidget() ) if ( (flags & fc::focus) != 0 && ! isWindowWidget() )
@ -1892,18 +1893,19 @@ bool FWidget::setCursorPos (register int x, register int y)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FWidget::setPrintPos (register int x, register int y) void FWidget::setPrintPos (register int x, register int y)
{ {
setPrintCursor ( offset.getX1() + adjust_wsize.getX() - 1 + x, setPrintCursor ( offset.getX1() + getX() + x - 1,
offset.getY1() + adjust_wsize.getY() - 1 + y ); offset.getY1() + getY() + y - 1 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
FPoint FWidget::getPrintPos() const FPoint FWidget::getPrintPos()
{ {
const FPoint* cur = FVTerm::getPrintPos(); const FPoint cur = getPrintCursor();
int cx = cur->getX(); int cx = cur.getX();
int cy = cur->getY(); int cy = cur.getY();
return FPoint ( cx - offset.getX1() - adjust_wsize.getX() + 1 return FPoint ( cx - offset.getX1() - getX() + 1
, cy - offset.getY1() - adjust_wsize.getY() + 1 ); , cy - offset.getY1() - getY() + 1 );
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -508,7 +508,7 @@ class FWidget : public FVTerm
void setPrintPos (const FPoint&); void setPrintPos (const FPoint&);
void setPrintPos (register int, register int); void setPrintPos (register int, register int);
FPoint getPrintPos() const; FPoint getPrintPos();
void drawShadow(); void drawShadow();
void clearShadow(); void clearShadow();