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-08 01:50:17 +0300
committerelfmz <fenix1905@tut.by>2022-11-08 01:50:17 +0300
commitb88b0ef6d90f5642b800b681a3c79e7b674ff146 (patch)
tree1ccdf8ac99caf4373b6a2663711e9f2702f1d319
parent47442dc490ad31edaa199af0f549a780f8dd1a62 (diff)
use right foreground colors in color selection boxes (fix #1392)
-rw-r--r--far2l/src/setcolor.cpp57
1 files changed, 57 insertions, 0 deletions
diff --git a/far2l/src/setcolor.cpp b/far2l/src/setcolor.cpp
index 82c4dffb..85df3512 100644
--- a/far2l/src/setcolor.cpp
+++ b/far2l/src/setcolor.cpp
@@ -531,6 +531,58 @@ void GetColor(int PaletteIndex)
}
}
+static void GetColorDlgProc_OnDrawn(HANDLE hDlg)
+{
+ // Trick to fix #1392:
+ // For foreground-colored boxes invert Fg&Bg colors and add COMMON_LVB_REVERSE_VIDEO attribute
+ // this will put real colors on them if mapping of colors is different for Fg and Bg indexes
+
+ // Ensure everything is on screen and will use console API then
+ ScrBuf.Flush();
+
+ SMALL_RECT DlgRect{};
+ SendDlgMessage(hDlg, DM_GETDLGRECT, 0, (LONG_PTR)&DlgRect);
+
+ for (int ID = 2; ID <= 17; ++ID)
+ {
+ SMALL_RECT ItemRect{};
+ if (SendDlgMessage(hDlg, DM_GETITEMPOSITION, ID, (LONG_PTR)&ItemRect))
+ {
+ ItemRect.Left+= DlgRect.Left;
+ ItemRect.Right+= DlgRect.Left;
+ ItemRect.Top+= DlgRect.Top;
+ ItemRect.Bottom+= DlgRect.Top;
+
+ CHAR_INFO ci{};
+ SMALL_RECT Rect = {ItemRect.Left, ItemRect.Top, ItemRect.Left, ItemRect.Top};
+ WINPORT(ReadConsoleOutput)(0, &ci, COORD{1, 1}, COORD{0, 0}, &Rect);
+ if (ci.Attributes & COMMON_LVB_REVERSE_VIDEO)
+ continue; // this cell is already tweaked during prev paint
+
+ DWORD64 InvColors = COMMON_LVB_REVERSE_VIDEO;
+
+ InvColors|= ((ci.Attributes & 0x0f) << 4) | ((ci.Attributes & 0xf0) >> 4);
+
+ InvColors|= (ci.Attributes & (COMMON_LVB_UNDERSCORE | COMMON_LVB_STRIKEOUT));
+
+ if (ci.Attributes & FOREGROUND_TRUECOLOR)
+ {
+ InvColors|= BACKGROUND_TRUECOLOR;
+ SET_RGB_BACK(InvColors, GET_RGB_FORE(ci.Attributes));
+ }
+
+ if (ci.Attributes & BACKGROUND_TRUECOLOR)
+ {
+ InvColors|= FOREGROUND_TRUECOLOR;
+ SET_RGB_FORE(InvColors, GET_RGB_BACK(ci.Attributes));
+ }
+
+ DWORD NumberOfAttrsWritten{};
+ WINPORT(FillConsoleOutputAttribute)(0, InvColors, ItemRect.Right - ItemRect.Left,
+ COORD{ItemRect.Left, ItemRect.Top}, &NumberOfAttrsWritten);
+ }
+ }
+}
static LONG_PTR WINAPI GetColorDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_PTR Param2)
{
@@ -575,12 +627,17 @@ static LONG_PTR WINAPI GetColorDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_PT
}
break;
+
+ case DN_DRAWDIALOGDONE:
+ GetColorDlgProc_OnDrawn(hDlg);
+ break;
}
return DefDlgProc(hDlg, Msg, Param1, Param2);
}
+
int GetColorDialog(WORD& Color,bool bCentered,bool bAddTransparent)
{
DialogDataEx ColorDlgData[]=