New Method setInsertCursorStyle()

This commit is contained in:
Markus Gans 2017-04-05 22:25:20 +02:00
parent 6b5f033b7b
commit 7f134ccada
5 changed files with 46 additions and 54 deletions

View File

@ -2,6 +2,8 @@
* Replace non-printable characters for Tera Term and * Replace non-printable characters for Tera Term and
Cygwin terminal directly at start-up. Special cases Cygwin terminal directly at start-up. Special cases
in the code are no longer necessary. in the code are no longer necessary.
* New Method setInsertCursorStyle() to change the appearance
of a cursor
2017-04-02 Markus Gans <guru.mail@muenster.de> 2017-04-02 Markus Gans <guru.mail@muenster.de>
* Remap the meta key to left alt key at runtime * Remap the meta key to left alt key at runtime

View File

@ -50,14 +50,7 @@ FLineEdit::FLineEdit (const FString& txt, FWidget* parent)
FLineEdit::~FLineEdit() // destructor FLineEdit::~FLineEdit() // destructor
{ {
if ( ! insert_mode ) if ( ! insert_mode )
{ setInsertCursorStyle();
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
} }
@ -314,23 +307,9 @@ void FLineEdit::onKeyPress (FKeyEvent* ev)
insert_mode = not insert_mode; insert_mode = not insert_mode;
if ( insert_mode ) if ( insert_mode )
{ setInsertCursorStyle();
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else else
{ unsetInsertCursorStyle();
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:eeee/0000/0000");
}
ev->accept(); ev->accept();
break; break;
@ -593,34 +572,16 @@ void FLineEdit::onAccel (FAccelEvent* ev)
void FLineEdit::onHide (FHideEvent*) void FLineEdit::onHide (FHideEvent*)
{ {
if ( ! insert_mode ) if ( ! insert_mode )
{ setInsertCursorStyle();
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FLineEdit::onFocusIn (FFocusEvent*) void FLineEdit::onFocusIn (FFocusEvent*)
{ {
if ( insert_mode ) if ( insert_mode )
{ setInsertCursorStyle();
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else else
{ unsetInsertCursorStyle();
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:0000/0000/0000");
}
if ( getStatusBar() ) if ( getStatusBar() )
{ {
@ -640,14 +601,7 @@ void FLineEdit::onFocusOut (FFocusEvent*)
} }
if ( ! insert_mode ) if ( ! insert_mode )
{ setInsertCursorStyle();
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
} }

View File

@ -703,6 +703,29 @@ bool FVTerm::isChildPrintArea() const
return false; return false;
} }
//----------------------------------------------------------------------
void FVTerm::setInsertCursorStyle (bool on)
{
if ( on )
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
}
else
{
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor, isCursorHidden());
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:eeee/0000/0000");
}
}
//---------------------------------------------------------------------- //----------------------------------------------------------------------
void FVTerm::createArea ( const FRect& r void FVTerm::createArea ( const FRect& r
, const FPoint& p , const FPoint& p

View File

@ -286,6 +286,11 @@ class FVTerm : public FObject, public FTerm
bool isChildPrintArea() const; bool isChildPrintArea() const;
bool isVirtualWindow() const; bool isVirtualWindow() const;
// Mutator
static void setInsertCursorStyle (bool on);
static void setInsertCursorStyle();
static void unsetInsertCursorStyle();
// Methods // Methods
void createArea ( const FRect& void createArea ( const FRect&
, const FPoint& , const FPoint&
@ -760,6 +765,14 @@ inline bool FVTerm::hasChildPrintArea() const
inline bool FVTerm::isVirtualWindow() const inline bool FVTerm::isVirtualWindow() const
{ return vwin; } { return vwin; }
//----------------------------------------------------------------------
inline void FVTerm::setInsertCursorStyle()
{ setInsertCursorStyle(true); }
//----------------------------------------------------------------------
inline void FVTerm::unsetInsertCursorStyle()
{ setInsertCursorStyle(false); }
//---------------------------------------------------------------------- //----------------------------------------------------------------------
inline void FVTerm::setPrintArea (term_area* area) inline void FVTerm::setPrintArea (term_area* area)
{ print_area = area; } { print_area = area; }

View File

@ -112,7 +112,7 @@ int main (int argc, char* argv[])
tcapString ( "| The SecDA String" tcapString ( "| The SecDA String"
, terminal->getSecDAString().c_str() ); , terminal->getSecDAString().c_str() );
std::cout << "'------------------- debug -------------------\r\n"; std::cout << "`------------------- debug -------------------\r\n";
#endif #endif
std::cout << "\r\n[Booleans]\r\n"; std::cout << "\r\n[Booleans]\r\n";