Change cursor style on a FreeBSD console

This commit is contained in:
Markus Gans 2017-04-06 01:31:21 +02:00
parent 7f134ccada
commit 0a581cb58b
7 changed files with 117 additions and 16 deletions

View File

@ -1,3 +1,6 @@
2017-04-06 Markus Gans <guru.mail@muenster.de>
* Change cursor style on a FreeBSD console
2017-04-05 Markus Gans <guru.mail@muenster.de>
* Replace non-printable characters for Tera Term and
Cygwin terminal directly at start-up. Special cases

View File

@ -929,7 +929,7 @@ class fc
};
// Linux console and framebuffer cursor style
enum consoleCursorStyle
enum linuxConsoleCursorStyle
{
default_cursor = 0,
invisible_cursor = 1,
@ -940,6 +940,14 @@ class fc
full_block_cursor = 6
};
// BSD console cursor style
enum bsdConsoleCursorStyle
{
normal_cursor = 0,
blink_cursor = 1,
destructive_cursor = 3
};
// KDE konsole cursor style
enum kdeKonsoleCursorShape
{

View File

@ -229,10 +229,13 @@ void FLabel::onAccel (FAccelEvent* ev)
FApplication::queueEvent(focused_widget, &out);
accel_widget->setFocus();
if ( focused_widget )
focused_widget->redraw();
accel_widget->redraw();
FFocusEvent in (fc::FocusIn_Event);
FApplication::sendEvent(accel_widget, &in);
if ( getStatusBar() )
{

View File

@ -109,7 +109,8 @@ bool FTermcap::no_utf8_acs_chars = false;
int FTermcap::max_color = 1;
int FTermcap::tabstop = 8;
int FTermcap::attr_without_color = 0;
fc::consoleCursorStyle FTerm::console_cursor_style;
fc::linuxConsoleCursorStyle FTerm::linux_console_cursor_style;
fc::bsdConsoleCursorStyle FTerm::bsd_console_cursor_style;
#if defined(__linux__)
console_font_op FTerm::screen_font;
@ -217,13 +218,21 @@ FTerm::modifier_key& FTerm::getModifierKey()
return mod_key;
}
#endif
//----------------------------------------------------------------------
fc::consoleCursorStyle FTerm::getConsoleCursor()
fc::linuxConsoleCursorStyle FTerm::getLinuxConsoleCursorStyle()
{
return console_cursor_style;
return linux_console_cursor_style;
}
#endif
#if defined(BSD)
//----------------------------------------------------------------------
fc::bsdConsoleCursorStyle FTerm::getBSDConsoleCursorStyle()
{
return bsd_console_cursor_style;
}
#endif
//----------------------------------------------------------------------
bool FTerm::isKeyTimeout (timeval* time, register long timeout)
@ -252,14 +261,17 @@ bool FTerm::isNormal (char_data*& ch)
return opti_attr->isNormal(ch);
}
#if defined(__linux__)
//----------------------------------------------------------------------
void FTerm::setConsoleCursor (fc::consoleCursorStyle style, bool hidden)
void FTerm::setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle style
, bool hidden )
{
// Set cursor style in linux console
if ( ! linux_terminal )
return;
console_cursor_style = style;
linux_console_cursor_style = style;
if ( hidden )
return;
@ -267,6 +279,26 @@ void FTerm::setConsoleCursor (fc::consoleCursorStyle style, bool hidden)
putstringf (CSI "?%dc", style);
std::fflush(stdout);
}
#endif
#if defined(BSD)
//----------------------------------------------------------------------
void FTerm::setBSDConsoleCursorStyle ( fc::bsdConsoleCursorStyle style
, bool hidden )
{
// Set cursor style in a BSD console
if ( ! isBSDConsole() )
return;
bsd_console_cursor_style = style;
if ( hidden )
return;
ioctl(0, CONS_CURSORTYPE, &style);
}
#endif
//----------------------------------------------------------------------
void FTerm::setTTY (termios& t)
@ -812,6 +844,7 @@ void FTerm::detectTermSize()
void FTerm::setTermSize (int term_width, int term_height)
{
// Set xterm size to {term_width} x {term_height}
if ( xterm_terminal )
{
putstringf (CSI "8;%d;%dt", term_height, term_width);
@ -823,6 +856,7 @@ void FTerm::setTermSize (int term_width, int term_height)
void FTerm::setKDECursor (fc::kdeKonsoleCursorShape style)
{
// Set cursor style in KDE konsole
if ( kde_konsole )
{
oscPrefix();
@ -958,6 +992,12 @@ const FString FTerm::getXTermColorName (int color)
void FTerm::setXTermCursorStyle (fc::xtermCursorStyle style)
{
// Set the xterm cursor style
#if defined(BSD)
if ( isBSDConsole() )
return;
#endif
if ( (xterm_terminal || mintty_terminal)
&& ! (gnome_terminal || kde_konsole) )
{
@ -3563,13 +3603,17 @@ void FTerm::init()
}
closeConsole();
setConsoleCursor(fc::underscore_cursor, true);
setLinuxConsoleCursorStyle (fc::underscore_cursor, true);
}
if ( linux_terminal && getFramebuffer_bpp() >= 4 )
FTermcap::max_color = 16;
#endif
#if defined(BSD)
setBSDConsoleCursorStyle (fc::destructive_cursor, true);
#endif
t.c_lflag |= uInt(ICANON | ECHO);
tcsetattr(stdin_no, TCSADRAIN, &t);
}
@ -3809,12 +3853,13 @@ void FTerm::finish()
if ( linux_terminal )
{
setBlinkAsIntensity (false);
setConsoleCursor(fc::default_cursor, false);
setLinuxConsoleCursorStyle (fc::default_cursor, false);
}
#endif
#if defined(BSD)
resetBSDAlt2Meta();
setBSDConsoleCursorStyle (fc::normal_cursor, false);
#endif
if ( kde_konsole )

View File

@ -43,6 +43,7 @@
#if defined(__unix__) || (defined(__APPLE__) && defined(__MACH__))
#include <sys/param.h>
#if defined(BSD)
#include <sys/consio.h>
#include <sys/kbio.h>
#endif
#endif
@ -120,14 +121,23 @@ class FTerm
static int getLineNumber();
static int getColumnNumber();
static const FString getKeyName (int);
#if defined(__linux__)
static modifier_key& getModifierKey();
#endif
static char* getTermType();
static char* getTermName();
static int getTabstop();
static int getMaxColor();
static fc::consoleCursorStyle getConsoleCursor();
#if defined(__linux__)
static fc::linuxConsoleCursorStyle getLinuxConsoleCursorStyle();
#endif
#if defined(BSD)
static fc::bsdConsoleCursorStyle getBSDConsoleCursorStyle();
#endif
#if DEBUG
static const FString& getAnswerbackString();
@ -166,7 +176,17 @@ class FTerm
// Mutators
static bool setCursorOptimisation (bool);
static void setXTermDefaultColors (bool);
static void setConsoleCursor (fc::consoleCursorStyle, bool);
#if defined(__linux__)
static void setLinuxConsoleCursorStyle ( fc::linuxConsoleCursorStyle
, bool );
#endif
#if defined(BSD)
static void setBSDConsoleCursorStyle ( fc::bsdConsoleCursorStyle
, bool );
#endif
static void setTTY (termios&);
static void noHardwareEcho();
static bool setRawMode (bool);
@ -427,7 +447,8 @@ class FTerm
static bool resize_term;
static struct termios term_init;
static fc::consoleCursorStyle console_cursor_style;
static fc::linuxConsoleCursorStyle linux_console_cursor_style;
static fc::bsdConsoleCursorStyle bsd_console_cursor_style;
static struct console_font_op screen_font;
static struct unimapdesc screen_unicode_map;
static uChar bsd_alt_keymap;

View File

@ -138,8 +138,15 @@ bool FVTerm::hideCursor (bool on)
flush_out();
#if defined(__linux__)
if ( ! hidden_cursor && isLinuxTerm() )
setConsoleCursor (getConsoleCursor(), false);
setLinuxConsoleCursorStyle (getLinuxConsoleCursorStyle(), false);
#endif
#if defined(BSD)
if ( ! hidden_cursor )
setBSDConsoleCursorStyle (getBSDConsoleCursorStyle(), false);
#endif
return hidden_cursor;
}
@ -710,7 +717,14 @@ void FVTerm::setInsertCursorStyle (bool on)
{
setXTermCursorStyle(fc::blinking_underline);
setKDECursor(fc::UnderlineCursor);
setConsoleCursor(fc::underscore_cursor, isCursorHidden());
#if defined(__linux__)
setLinuxConsoleCursorStyle (fc::underscore_cursor, isCursorHidden());
#endif
#if defined(BSD)
setBSDConsoleCursorStyle (fc::destructive_cursor, isCursorHidden());
#endif
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:ffff/ffff/ffff");
@ -719,7 +733,14 @@ void FVTerm::setInsertCursorStyle (bool on)
{
setXTermCursorStyle(fc::steady_block);
setKDECursor(fc::BlockCursor);
setConsoleCursor(fc::full_block_cursor, isCursorHidden());
#if defined(__linux__)
setLinuxConsoleCursorStyle (fc::full_block_cursor, isCursorHidden());
#endif
#if defined(BSD)
setBSDConsoleCursorStyle (fc::normal_cursor, isCursorHidden());
#endif
if ( isUrxvtTerminal() )
setXTermCursorColor("rgb:eeee/0000/0000");