Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/elfmz/far2l.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorelfmz <fenix1905@tut.by>2022-11-07 17:22:05 +0300
committerelfmz <fenix1905@tut.by>2022-11-07 17:40:09 +0300
commite1c7f10e98950f3f35473b34f3970e63346053e0 (patch)
tree3cfba39e1e537aee8180a9c951b5beb4f2ddfc42 /WinPort
parentfa30944de1bd03ca9e2bfdf6ad82085a5b730f59 (diff)
use truecolor in colorer by adopting truemod functionality and extending editor API
Diffstat (limited to 'WinPort')
-rw-r--r--WinPort/WinCompat.h1
-rw-r--r--WinPort/src/Backend/TTY/TTYOutput.cpp6
-rw-r--r--WinPort/src/Backend/WX/Paint.cpp28
-rw-r--r--WinPort/src/Backend/WX/Paint.h3
4 files changed, 29 insertions, 9 deletions
diff --git a/WinPort/WinCompat.h b/WinPort/WinCompat.h
index 17286f60..f30fd733 100644
--- a/WinPort/WinCompat.h
+++ b/WinPort/WinCompat.h
@@ -611,6 +611,7 @@ typedef struct _INPUT_RECORD {
#define BACKGROUND_TRUECOLOR 0x0200 // Use 24 bit RGB colors set by SET_RGB_BACK
#define COMMON_LVB_REVERSE_VIDEO 0x4000 // Reverse fore/back ground attribute.
#define COMMON_LVB_UNDERSCORE 0x8000 // Underscore.
+#define COMMON_LVB_STRIKEOUT 0x2000 // Striekout.
// Constants below not implemented and their bit values are reserved and must be zero-inited
// #define COMMON_LVB_GRID_HORIZONTAL
diff --git a/WinPort/src/Backend/TTY/TTYOutput.cpp b/WinPort/src/Backend/TTY/TTYOutput.cpp
index 8f8ca44b..22924574 100644
--- a/WinPort/src/Backend/TTY/TTYOutput.cpp
+++ b/WinPort/src/Backend/TTY/TTYOutput.cpp
@@ -22,7 +22,7 @@
#define ATTRIBUTES_AFFECTING_BACKGROUND \
(BACKGROUND_BLUE | BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_INTENSITY \
- | BACKGROUND_TRUECOLOR | COMMON_LVB_REVERSE_VIDEO | COMMON_LVB_UNDERSCORE)
+ | BACKGROUND_TRUECOLOR | COMMON_LVB_REVERSE_VIDEO | COMMON_LVB_UNDERSCORE | COMMON_LVB_STRIKEOUT)
void TTYOutput::TrueColors::AppendSuffix(std::string &out, DWORD rgb)
{
@@ -99,6 +99,10 @@ void TTYOutput::WriteUpdatedAttributes(DWORD64 attr, bool is_space)
_true_colors.AppendSuffix(_tmp_attrs, GET_RGB_BACK(attr));
}
+ if ( (xa & COMMON_LVB_STRIKEOUT) != 0) {
+ _tmp_attrs+= (attr & COMMON_LVB_STRIKEOUT) ? "9;" : "29;";
+ }
+
if ( (xa & COMMON_LVB_UNDERSCORE) != 0) {
_tmp_attrs+= (attr & COMMON_LVB_UNDERSCORE) ? "4;" : "24;";
}
diff --git a/WinPort/src/Backend/WX/Paint.cpp b/WinPort/src/Backend/WX/Paint.cpp
index d6f47725..1eabb702 100644
--- a/WinPort/src/Backend/WX/Paint.cpp
+++ b/WinPort/src/Backend/WX/Paint.cpp
@@ -506,7 +506,8 @@ void CursorProps::Update()
ConsolePainter::ConsolePainter(ConsolePaintContext *context, wxPaintDC &dc, wxString &buffer, CursorProps &cursor_props) :
_context(context), _dc(dc), _buffer(buffer), _cursor_props(cursor_props),
- _start_cx((unsigned int)-1), _start_back_cx((unsigned int)-1), _prev_fit_font_index(0), _prev_underlined(false)
+ _start_cx((unsigned int)-1), _start_back_cx((unsigned int)-1), _prev_fit_font_index(0),
+ _prev_underlined(false), _prev_strikeout(false)
{
_dc.SetPen(context->GetTransparentPen());
_dc.SetBackgroundMode(wxPENSTYLE_TRANSPARENT);
@@ -575,20 +576,31 @@ void ConsolePainter::FlushText(unsigned int cx_end)
_dc.DrawText(_buffer, _start_cx * _context->FontWidth(), _start_y);
_buffer.Empty();
}
- FlushUnderline(cx_end);
+ FlushDecorations(cx_end);
_start_cx = (unsigned int)-1;
_prev_fit_font_index = 0;
}
-void ConsolePainter::FlushUnderline(unsigned int cx_end)
+void ConsolePainter::FlushDecorations(unsigned int cx_end)
{
+ if (!_prev_underlined && !_prev_strikeout) {
+ return;
+ }
+ _dc.SetPen(wxColour(_clr_text.r, _clr_text.g, _clr_text.b));
+
if (_prev_underlined) {
- _dc.SetPen(wxColour(_clr_text.r, _clr_text.g, _clr_text.b));
_dc.DrawLine(_start_cx * _context->FontWidth(), _start_y + _context->FontHeight() - 1,
cx_end * _context->FontWidth(), _start_y + _context->FontHeight() - 1);
- _dc.SetPen(_context->GetTransparentPen());
_prev_underlined = false;
}
+
+ if (_prev_strikeout) {
+ _dc.DrawLine(_start_cx * _context->FontWidth(), _start_y + (_context->FontHeight() / 2),
+ cx_end * _context->FontWidth(), _start_y + (_context->FontHeight() / 2));
+ _prev_strikeout = false;
+ }
+
+ _dc.SetPen(_context->GetTransparentPen());
}
static inline unsigned char CalcFadeColor(unsigned char bg, unsigned char fg)
@@ -710,7 +722,7 @@ void ConsolePainter::NextChar(unsigned int cx, DWORD64 attributes, const wchar_t
FlushBackground(cx + nx);
WXCustomDrawCharPainter cdp(*this, clr_text, clr_back);
custom_draw(cdp, _start_y, cx);
- FlushUnderline(cx);
+ FlushDecorations(cx);
_start_cx = (unsigned int)-1;
_prev_fit_font_index = 0;
return;
@@ -718,8 +730,9 @@ void ConsolePainter::NextChar(unsigned int cx, DWORD64 attributes, const wchar_t
uint8_t fit_font_index = _context->CharFitTest(_dc, wcz);
const bool underlined = (attributes & COMMON_LVB_UNDERSCORE) != 0;
+ const bool strikeout = (attributes & COMMON_LVB_STRIKEOUT) != 0;
- if (fit_font_index == _prev_fit_font_index && _prev_underlined == underlined
+ if (fit_font_index == _prev_fit_font_index && _prev_underlined == underlined && _prev_strikeout == strikeout
&& _start_cx != (unsigned int)-1 && _clr_text == clr_text && _context->IsPaintBuffered()) {
_buffer+= wcz;
return;
@@ -730,6 +743,7 @@ void ConsolePainter::NextChar(unsigned int cx, DWORD64 attributes, const wchar_t
_prev_fit_font_index = fit_font_index;
_prev_underlined = underlined;
+ _prev_strikeout = strikeout;
_start_cx = cx;
_buffer = wcz;
diff --git a/WinPort/src/Backend/WX/Paint.h b/WinPort/src/Backend/WX/Paint.h
index b61199be..5127e2ab 100644
--- a/WinPort/src/Backend/WX/Paint.h
+++ b/WinPort/src/Backend/WX/Paint.h
@@ -99,6 +99,7 @@ class ConsolePainter
unsigned int _start_y;
uint8_t _prev_fit_font_index;
bool _prev_underlined;
+ bool _prev_strikeout;
std::map<WinPortRGB, wxPen *> _custom_draw_pens;
friend struct WXCustomDrawCharPainter;
@@ -107,7 +108,7 @@ class ConsolePainter
void PrepareBackground(unsigned int cx, const WinPortRGB &clr, unsigned int nx);
void FlushBackground(unsigned int cx_end);
void FlushText(unsigned int cx_end);
- void FlushUnderline(unsigned int cx_end);
+ void FlushDecorations(unsigned int cx_end);
public:
ConsolePainter(ConsolePaintContext *context, wxPaintDC &dc, wxString &_buffer, CursorProps &cursor_props);