Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RGB pal testing #2206

Merged
merged 7 commits into from
May 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 17 additions & 6 deletions NetRocks/src/UI/Activities/ComplexOperationProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ void ComplexOperationProgress::OnIdle()
bool path, file, all, count, errors;
} changed = {};
bool paused;
uint64_t Colors[4];
{
std::lock_guard<std::mutex> locker(_state.mtx);
if (_last_path != _state.path) {
Expand Down Expand Up @@ -204,15 +205,25 @@ void ComplexOperationProgress::OnIdle()
TextToDialogControl(_i_errstats_separator, sz);
if (!_errstats_colored) {
_errstats_colored = true;
DWORD color_flags = 0;
SendDlgMessage(DM_GETCOLOR, _i_errstats_separator, (LONG_PTR)&color_flags);
color_flags&= ~(FOREGROUND_GREEN | FOREGROUND_BLUE);
color_flags|= DIF_SETCOLOR | FOREGROUND_RED;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, color_flags);

SendDlgMessage(DM_GETDEFAULTCOLOR, _i_errstats_separator, (LONG_PTR)Colors);
Colors[0] &= ~(0x000000FFFF000000 | FOREGROUND_GREEN | FOREGROUND_BLUE);
Colors[0] |= (0x0000000000FF0000 | FOREGROUND_RED);
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, (LONG_PTR)Colors);

// DWORD color_flags = 0;
// SendDlgMessage(DM_GETCOLOR, _i_errstats_separator, (LONG_PTR)&color_flags);
// color_flags&= ~(FOREGROUND_GREEN | FOREGROUND_BLUE);
// color_flags|= DIF_SETCOLOR | FOREGROUND_RED;
// SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, color_flags);
}
} else if (_errstats_colored) {
_errstats_colored = false;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, 0);

Colors[0] = 0;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, (LONG_PTR)Colors);

// SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, 0);
}

const bool has_any_auto_action = _wea_state->HasAnyAutoAction();
Expand Down
25 changes: 19 additions & 6 deletions NetRocks/src/UI/Activities/SimpleOperationProgress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ void SimpleOperationProgress::Show()

LONG_PTR SimpleOperationProgress::DlgProc(int msg, int param1, LONG_PTR param2)
{
uint64_t Colors[4];

//fprintf(stderr, "%x %x\n", msg, param1);
if (msg == DN_ENTERIDLE) {
bool count_complete_changed = false, errors_changed = false;
Expand Down Expand Up @@ -81,15 +83,26 @@ LONG_PTR SimpleOperationProgress::DlgProc(int msg, int param1, LONG_PTR param2)
TextToDialogControl(_i_errstats_separator, sz);
if (!_errstats_colored) {
_errstats_colored = true;
DWORD color_flags = 0;
SendDlgMessage(DM_GETCOLOR, _i_errstats_separator, (LONG_PTR)&color_flags);
color_flags&= ~(FOREGROUND_GREEN | FOREGROUND_BLUE);
color_flags|= DIF_SETCOLOR | FOREGROUND_RED;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, color_flags);

SendDlgMessage(DM_GETDEFAULTCOLOR, _i_errstats_separator, (LONG_PTR)Colors);
Colors[0] &= ~(0x000000FFFF000000 | FOREGROUND_GREEN | FOREGROUND_BLUE);
Colors[0] |= (0x0000000000FF0000 | FOREGROUND_RED);
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, (LONG_PTR)Colors);

// DWORD color_flags = 0;
// SendDlgMessage(DM_GETCOLOR, _i_errstats_separator, (LONG_PTR)&color_flags);
// color_flags&= ~(FOREGROUND_GREEN | FOREGROUND_BLUE);
// color_flags|= DIF_SETCOLOR | FOREGROUND_RED;
// SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, color_flags);

}
} else if (_errstats_colored) {
_errstats_colored = false;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, 0);

Colors[0] = 0;
SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, (LONG_PTR)Colors);

// SendDlgMessage(DM_SETCOLOR, _i_errstats_separator, 0);
}


Expand Down
3 changes: 3 additions & 0 deletions WinPort/WinPort.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ extern "C" {
WINPORT_DECL(SetConsoleWindowMaximized,VOID,(BOOL Maximized));
WINPORT_DECL(GetConsoleColorPalette,BYTE,(HANDLE hConsoleOutput)); // Returns current color resolution: 4, 8, 24

WINPORT_DECL(GetConsoleBasePalette,VOID,(HANDLE hConsoleOutput, void *p));
WINPORT_DECL(SetConsoleBasePalette,BOOL,(HANDLE hConsoleOutput, void *p));

WINPORT_DECL(GenerateConsoleCtrlEvent, BOOL, (DWORD dwCtrlEvent, DWORD dwProcessGroupId ));
WINPORT_DECL(SetConsoleCtrlHandler, BOOL, (PHANDLER_ROUTINE HandlerRoutine, BOOL Add ));

Expand Down
10 changes: 10 additions & 0 deletions WinPort/src/APIConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,16 @@ extern "C" {
return ChooseConOut(hConsoleOutput)->GetColorPalette();
}

WINPORT_DECL(GetConsoleBasePalette,VOID,(HANDLE hConsoleOutput, VOID *p))
{
return ChooseConOut(hConsoleOutput)->GetBasePalette(p);
}

WINPORT_DECL(SetConsoleBasePalette,BOOL,(HANDLE hConsoleOutput, VOID *p))
{
return ChooseConOut(hConsoleOutput)->SetBasePalette(p);
}

WINPORT_DECL(OverrideConsoleColor, VOID, (HANDLE hConsoleOutput, DWORD Index, DWORD *ColorFG, DWORD *ColorBK))
{
return ChooseConOut(hConsoleOutput)->OverrideColor(Index, ColorFG, ColorBK);
Expand Down
4 changes: 4 additions & 0 deletions WinPort/src/Backend/Backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class IConsoleOutputBackend
virtual bool OnConsoleBackgroundMode(bool TryEnterBackgroundMode) = 0;
virtual bool OnConsoleSetFKeyTitles(const char **titles) = 0;
virtual BYTE OnConsoleGetColorPalette() = 0;
virtual void OnConsoleGetBasePalette(void *pbuff) = 0;
virtual bool OnConsoleSetBasePalette(void *pbuff) = 0;
virtual void OnConsoleOverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK) = 0;
virtual void OnConsoleSetCursorBlinkTime(DWORD interval) = 0;
};
Expand Down Expand Up @@ -205,6 +207,8 @@ class IConsoleOutput
virtual bool ConsoleBackgroundMode(bool TryEnterBackgroundMode) = 0;
virtual bool SetFKeyTitles(const CHAR **titles) = 0;
virtual BYTE GetColorPalette() = 0;
virtual void GetBasePalette(void *p) = 0;
virtual bool SetBasePalette(void *p) = 0;
virtual void OverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK) = 0;
virtual void RepaintsDeferStart() = 0;
virtual void RepaintsDeferFinish() = 0;
Expand Down
39 changes: 31 additions & 8 deletions WinPort/src/Backend/TTY/TTYBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,20 +783,17 @@ DWORD64 TTYBackend::OnConsoleSetTweaks(DWORD64 tweaks)
}

bool override_default_palette = (tweaks & CONSOLE_TTY_PALETTE_OVERRIDE) != 0;

{
std::lock_guard<std::mutex> lock(_palette_mtx);
std::swap(override_default_palette, _override_default_palette);
}

if (override_default_palette != ((tweaks & CONSOLE_TTY_PALETTE_OVERRIDE) != 0)) {
{
std::unique_lock<std::mutex> lock(_async_mutex);
_ae.palette = true;
_async_cond.notify_all();
while (_ae.palette) {
_async_cond.wait(lock);
}
std::unique_lock<std::mutex> lock(_async_mutex);
_ae.palette = true;
_async_cond.notify_all();
while (_ae.palette) {
_async_cond.wait(lock);
}
}

Expand Down Expand Up @@ -836,6 +833,32 @@ void TTYBackend::OnConsoleOverrideColor(DWORD Index, DWORD *ColorFG, DWORD *Colo
}
}

void TTYBackend::OnConsoleGetBasePalette(void *pbuff)
{
memcpy(pbuff, &g_winport_palette, BASE_PALETTE_SIZE * sizeof(DWORD) * 2);

return;
}

bool TTYBackend::OnConsoleSetBasePalette(void *pbuff)
{
if (!pbuff) return false;

{
std::unique_lock<std::mutex> lock(_palette_mtx);
memcpy(&_palette, pbuff, BASE_PALETTE_SIZE * sizeof(DWORD) * 2);
}

std::unique_lock<std::mutex> lock(_async_mutex);
_ae.palette = true;
_async_cond.notify_all();
while (_ae.palette) {
_async_cond.wait(lock);
}

return true;
}

void TTYBackend::OnConsoleChangeFont()
{
}
Expand Down
2 changes: 2 additions & 0 deletions WinPort/src/Backend/TTY/TTYBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ class TTYBackend : IConsoleOutputBackend, ITTYInputSpecialSequenceHandler, IFar2
virtual bool OnConsoleBackgroundMode(bool TryEnterBackgroundMode);
virtual bool OnConsoleSetFKeyTitles(const char **titles);
virtual BYTE OnConsoleGetColorPalette();
virtual void OnConsoleGetBasePalette(void *pbuff);
virtual bool OnConsoleSetBasePalette(void *pbuff);
virtual void OnConsoleOverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK);
virtual void OnConsoleSetCursorBlinkTime(DWORD interval);

Expand Down
21 changes: 21 additions & 0 deletions WinPort/src/Backend/WX/wxMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1814,6 +1814,27 @@ static void ConsoleOverrideColorInMain(DWORD Index, DWORD *ColorFG, DWORD *Color
g_wx_palette.background[Index] = bk;
}

static void ConsoleOverrideBasePaletteInMain(void *pbuff)
{
memcpy(&g_wx_palette, pbuff, BASE_PALETTE_SIZE * sizeof(WinPortRGB) * 2);
}

void WinPortPanel::OnConsoleGetBasePalette(void *pbuff)
{
memcpy(pbuff, &g_wx_palette, BASE_PALETTE_SIZE * sizeof(WinPortRGB) * 2);
}

bool WinPortPanel::OnConsoleSetBasePalette(void *pbuff)
{
if (!pbuff)
return false;

auto fn = std::bind(&ConsoleOverrideBasePaletteInMain, pbuff);
CallInMainNoRet(fn);

return true;
}

void WinPortPanel::OnConsoleOverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK)
{
if (Index >= BASE_PALETTE_SIZE) {
Expand Down
2 changes: 2 additions & 0 deletions WinPort/src/Backend/WX/wxMain.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class WinPortPanel: public wxPanel, protected IConsoleOutputBackend
virtual bool OnConsoleBackgroundMode(bool TryEnterBackgroundMode);
virtual bool OnConsoleSetFKeyTitles(const char **titles);
virtual BYTE OnConsoleGetColorPalette();
virtual void OnConsoleGetBasePalette(void *pbuff);
virtual bool OnConsoleSetBasePalette(void *pbuff);
virtual void OnConsoleOverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK);
virtual void OnConsoleSetCursorBlinkTime(DWORD interval);

Expand Down
6 changes: 3 additions & 3 deletions WinPort/src/Backend/WinPortRGB.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ struct WinPortRGB
unsigned char r;
unsigned char g;
unsigned char b;
unsigned char a;

inline WinPortRGB(DWORD rgb = 0) : r(rgb & 0xff), g((rgb >> 8) & 0xff), b((rgb >> 16) & 0xff) {}
inline WinPortRGB(unsigned char r_, unsigned char g_, unsigned char b_) : r(r_), g(g_), b(b_) {}
inline WinPortRGB(DWORD rgb = 0) : r(rgb & 0xff), g((rgb >> 8) & 0xff), b((rgb >> 16) & 0xff), a(0) {}
inline WinPortRGB(unsigned char r_, unsigned char g_, unsigned char b_) : r(r_), g(g_), b(b_), a(0) {}

inline bool operator == (const WinPortRGB &rgb) const
{
Expand Down Expand Up @@ -36,7 +37,6 @@ struct WinPortRGB
return uint32_t(r) | (uint32_t(g) << 8) | (uint32_t(b) << 16);
}


inline uint32_t AsBGR() const
{
return uint32_t(b) | (uint32_t(g) << 8) | (uint32_t(r) << 16);
Expand Down
11 changes: 11 additions & 0 deletions WinPort/src/ConsoleOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,17 @@ BYTE ConsoleOutput::GetColorPalette()
return _backend ? _backend->OnConsoleGetColorPalette() : 4;
}

VOID ConsoleOutput::GetBasePalette(VOID *p)
{
if (_backend)
_backend->OnConsoleGetBasePalette(p);
}

bool ConsoleOutput::SetBasePalette(VOID *p)
{
return (_backend && _backend->OnConsoleSetBasePalette(p));
}

void ConsoleOutput::OverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK)
{
if (_backend)
Expand Down
2 changes: 2 additions & 0 deletions WinPort/src/ConsoleOutput.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ class ConsoleOutput : public IConsoleOutput
virtual bool ConsoleBackgroundMode(bool TryEnterBackgroundMode);
virtual bool SetFKeyTitles(const CHAR **titles);
virtual BYTE GetColorPalette();
virtual void GetBasePalette(void *p);
virtual bool SetBasePalette(void *p);
virtual void OverrideColor(DWORD Index, DWORD *ColorFG, DWORD *ColorBK);
virtual void RepaintsDeferStart();
virtual void RepaintsDeferFinish();
Expand Down
2 changes: 2 additions & 0 deletions WinPort/windows.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
#define FillConsoleOutputCharacter WINPORT(FillConsoleOutputCharacter)
#define SetConsoleActiveScreenBuffer WINPORT(SetConsoleActiveScreenBuffer)
#define SetConsoleCursorBlinkTime WINPORT(SetConsoleCursorBlinkTime)
#define GetConsoleBasePalette WINPORT(GetConsoleBasePalette)
#define SetConsoleBasePalette WINPORT(SetConsoleBasePalette)

#define FlushConsoleInputBuffer WINPORT(FlushConsoleInputBuffer)
#define GetNumberOfConsoleInputEvents WINPORT(GetNumberOfConsoleInputEvents)
Expand Down
2 changes: 1 addition & 1 deletion colorer/src/pcolorer2/FarEditorSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1111,7 +1111,7 @@ bool FarEditorSet::SetBgEditor()
{
if (rEnabled && ChangeBgEditor && !consoleAnnotationAvailable) {
FarSetColors fsc;
unsigned char c;
uint64_t c;

const StyledRegion* def_text =
StyledRegion::cast(regionMapper->getRegionDefine(UnicodeString("def:Text")));
Expand Down
36 changes: 18 additions & 18 deletions far2l/bootstrap/scripts/farlang.templ.m4
Original file line number Diff line number Diff line change
Expand Up @@ -11698,15 +11698,15 @@ l:
"Меню фільтраў"

FilterBottom
"+,-,Пробел,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"+,-,Space,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"+,-,Mezera,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"+,-,Leer,I,X,BS,UmschBS,Einf,Entf,F4,F5,StrgUp,StrgDn"
"+,-,Szóköz,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Fel,Ctrl-Le"
"+,-,Spacja,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"Seleccione: '+','-',Space. Editor: Ins,Del,F4"
"+,-,Пробіл,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"+,-,Space,I,X,BS,Shift-BS,Ins,Del,F4,F5,Ctrl-Up,Ctrl-Dn"
"+ - Пробел I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"
"+ - Space I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"
"+ - Mezera I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"
"+ - Leer I X BS UmschBS Einf Entf F4 F5 StrgUp StrgDn"
"+ - Szóköz I X BS Shift+BS Ins Del F4 F5 Ctrl+Fel Ctrl+Le"
"+ - Spacja I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"
"Seleccione: '+' '-' Space. Editor: Ins Del F4"
"+ - Пробіл I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"
"+ - Space I X BS Shift+BS Ins Del F4 F5 Ctrl+Up Ctrl+Dn"

PanelFileType
"Файлы панели"
Expand Down Expand Up @@ -12421,15 +12421,15 @@ l:
"Афарбоўка файлаў"

HighlightBottom
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"Ins,Del,F4,F5,Ctrl-Nahoru,Ctrl-Dolů"
"Einf,Entf,F4,F5,StrgUp,StrgDown"
"Ins,Del,F4,F5,Ctrl-Fel,Ctrl-Le"
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"Ins,Del,F4,F5,Ctrl-Up,Ctrl-Down"
"+ - Пробел Ins Del F4 F5 Ctrl+Up Ctrl+Down Ctrl+R"
"+ - Space Ins Del F4 F5 Ctrl+Up Ctrl+Down"
"+ - Mezera Ins Del F4 F5 Ctrl+Nahoru Ctrl+Dolů"
"+ - Leer Einf Entf F4 F5 StrgUp,StrgDown"
"+ - Szóköz Ins Del F4 F5 Ctrl+Fel Ctrl+Le"
"+ - Spacja Ins Del F4 F5 Ctrl+Up Ctrl+Down"
"+ - Space Ins Del F4 F5 Ctrl+Up Ctrl+Down"
"+ - Пробіл Ins Del F4 F5 Ctrl+Up Ctrl+Down"
"+ - Space Ins Del F4 F5 Ctrl+Up Ctrl+Down"

HighlightUpperSortGroup
"Верхняя группа сортировки"
Expand Down
2 changes: 1 addition & 1 deletion far2l/far2sdk/farplug-mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ namespace oldfar
DWORD Flags;
DWORD Reserved;
int ColorCount;
LPBYTE Colors;
uint64_t *Colors;
};

struct FarDialogItem
Expand Down
18 changes: 10 additions & 8 deletions far2l/far2sdk/farplug-wide.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,13 +343,16 @@ enum FarMessagesProc

DM_GETDIALOGINFO,

DM_GETCOLOR,
DM_SETCOLOR,

DM_SETREADONLY,

DM_GETTRUECOLOR, // Param1 - Item ID, Param2 - DialogItemTrueColors *
DM_SETTRUECOLOR, // Param1 - Item ID, Param2 - const DialogItemTrueColors *
// DM_GETCOLOR,
// DM_SETCOLOR,
DM_GETDEFAULTCOLOR, // Param1 - Item ID, Param2 - uint64_t * -> uint64_t ItemColors[4]

DM_GETTRUECOLOR, // Param1 - Item ID, Param2 - uint64_t * -> uint64_t ItemColors[4]
DM_GETCOLOR = DM_GETTRUECOLOR,
DM_SETTRUECOLOR, // Param1 - Item ID, Param2 - uint64_t * -> uint64_t ItemColors[4]
DM_SETCOLOR = DM_SETTRUECOLOR,

DM_SETTEXTPTRSILENT,

Expand Down Expand Up @@ -519,10 +522,9 @@ struct FarListColors
DWORD Flags;
DWORD Reserved;
int ColorCount;
LPBYTE Colors;
uint64_t *Colors;
};


struct FarDialogItem
{
int Type;
Expand Down Expand Up @@ -1349,7 +1351,7 @@ struct FarSetColors
DWORD Flags;
int StartIndex;
int ColorCount;
LPBYTE Colors;
uint64_t *Colors;
};

struct FarTrueColor
Expand Down