From 6d4c0fa4e7673794aae9afcdee512be4d913c8ba Mon Sep 17 00:00:00 2001 From: m32 Date: Mon, 17 Jun 2024 14:16:22 +0200 Subject: [PATCH 01/27] confusing space in name --- python/configs/plug/plugins/uadb.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/configs/plug/plugins/uadb.py b/python/configs/plug/plugins/uadb.py index 569d8eb2e..c93464b09 100644 --- a/python/configs/plug/plugins/uadb.py +++ b/python/configs/plug/plugins/uadb.py @@ -372,13 +372,14 @@ def addResult(self, result): for rec in result: if rec.name in (".", ".."): continue + name = rec.name.replace('\\ ', ' ') attr = 0 attr |= FILE_ATTRIBUTE_DIRECTORY if rec.mode & stat.S_IFDIR else 0 attr |= FILE_ATTRIBUTE_DEVICE if rec.mode & stat.S_IFCHR else 0 attr |= FILE_ATTRIBUTE_ARCHIVE if rec.mode & stat.S_IFREG else 0 - # log.debug('{} mode={:5o} attr={} perms={}'.format(rec.name, rec.mode, attr, rec.perms)) + # log.debug('{} mode={:5o} attr={} perms={}'.format(name, rec.mode, attr, rec.perms)) # datetime.datetime.fromtimestamp(rec.time).strftime('%Y-%m-%d %H:%M:%S') - item = self.setName(i, rec.name, attr, rec.size) + item = self.setName(i, name, attr, rec.size) item.dwUnixMode = rec.mode t = ( From c2ba1e9512ac273d14f84ca8e2e723a22afc0b62 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 1 Sep 2024 04:43:22 +0200 Subject: [PATCH 02/27] dramatically improve keyboard events logging --- WinPort/src/Backend/WX/wxMain.cpp | 7 +- WinPort/src/ConsoleInput.cpp | 311 +++++++++++++++++++++++++++++- 2 files changed, 311 insertions(+), 7 deletions(-) diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp index be62bbdf8..2f6755827 100644 --- a/WinPort/src/Backend/WX/wxMain.cpp +++ b/WinPort/src/Backend/WX/wxMain.cpp @@ -1114,7 +1114,7 @@ void WinPortPanel::OnKeyDown( wxKeyEvent& event ) ResetTimerIdling(); DWORD now = WINPORT(GetTickCount)(); const auto uni = event.GetUnicodeKey(); - fprintf(stderr, "OnKeyDown: raw=%x code=%x uni=%x (%lc) ts=%lu [now=%u]", + fprintf(stderr, "\nOnKeyDown: raw=%x code=%x uni=%x (%lc) ts=%lu [now=%u]", event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp(), now); @@ -1233,7 +1233,7 @@ void WinPortPanel::OnKeyUp( wxKeyEvent& event ) { ResetTimerIdling(); const auto uni = event.GetUnicodeKey(); - fprintf(stderr, "OnKeyUp: raw=%x code=%x uni=%x (%lc) ts=%lu", + fprintf(stderr, "\nOnKeyUp: raw=%x code=%x uni=%x (%lc) ts=%lu", event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp()); @@ -1311,6 +1311,9 @@ void WinPortPanel::OnChar( wxKeyEvent& event ) { ResetTimerIdling(); const auto uni = event.GetUnicodeKey(); + if (_key_tracker.LastKeydown().GetTimestamp() != event.GetTimestamp()) { + fprintf(stderr, "\n"); + } fprintf(stderr, "OnChar: raw=%x code=%x uni=%x (%lc) ts=%lu lke=%u", event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp(), _last_keydown_enqueued); diff --git a/WinPort/src/ConsoleInput.cpp b/WinPort/src/ConsoleInput.cpp index 1168b07eb..41bf45d2b 100644 --- a/WinPort/src/ConsoleInput.cpp +++ b/WinPort/src/ConsoleInput.cpp @@ -1,17 +1,318 @@ #include #include "ConsoleInput.h" +const char* VirtualKeyNames[] = { + "ERR", // 0x00 + "VK_LBUTTON", // 0x01 + "VK_RBUTTON", // 0x02 + "VK_CANCEL", // 0x03 + "VK_MBUTTON", // 0x04 + "VK_XBUTTON1", // 0x05 + "VK_XBUTTON2", // 0x06 + "ERR", // 0x07 + "VK_BACK", // 0x08 + "VK_TAB", // 0x09 + "ERR", // 0x0A + "ERR", // 0x0B + "VK_CLEAR", // 0x0C + "VK_RETURN", // 0x0D + "ERR", // 0x0E + "ERR", // 0x0F + "VK_SHIFT", // 0x10 + "VK_CONTROL", // 0x11 + "VK_MENU", // 0x12 + "VK_PAUSE", // 0x13 + "VK_CAPITAL", // 0x14 + "VK_HANGUEL", // 0x15 + "ERR", // 0x16 + "VK_JUNJA", // 0x17 + "VK_FINAL", // 0x18 + "VK_HANJA", // 0x19 + "ERR", // 0x1A + "VK_ESCAPE", // 0x1B + "VK_CONVERT", // 0x1C + "VK_NONCONVERT", // 0x1D + "VK_ACCEPT", // 0x1E + "VK_MODECHANGE", // 0x1F + "VK_SPACE", // 0x20 + "VK_PRIOR", // 0x21 + "VK_NEXT", // 0x22 + "VK_END", // 0x23 + "VK_HOME", // 0x24 + "VK_LEFT", // 0x25 + "VK_UP", // 0x26 + "VK_RIGHT", // 0x27 + "VK_DOWN", // 0x28 + "VK_SELECT", // 0x29 + "VK_PRINT", // 0x2A + "VK_EXECUTE", // 0x2B + "VK_SNAPSHOT", // 0x2C + "VK_INSERT", // 0x2D + "VK_DELETE", // 0x2E + "VK_HELP", // 0x2F + "VK_0", // 0x30 + "VK_1", // 0x31 + "VK_2", // 0x32 + "VK_3", // 0x33 + "VK_4", // 0x34 + "VK_5", // 0x35 + "VK_6", // 0x36 + "VK_7", // 0x37 + "VK_8", // 0x38 + "VK_9", // 0x39 + "ERR", // 0x3A + "ERR", // 0x3B + "ERR", // 0x3C + "ERR", // 0x3D + "ERR", // 0x3E + "ERR", // 0x3F + "ERR", // 0x40 + "VK_A", // 0x41 + "VK_B", // 0x42 + "VK_C", // 0x43 + "VK_D", // 0x44 + "VK_E", // 0x45 + "VK_F", // 0x46 + "VK_G", // 0x47 + "VK_H", // 0x48 + "VK_I", // 0x49 + "VK_J", // 0x4A + "VK_K", // 0x4B + "VK_L", // 0x4C + "VK_M", // 0x4D + "VK_N", // 0x4E + "VK_O", // 0x4F + "VK_P", // 0x50 + "VK_Q", // 0x51 + "VK_R", // 0x52 + "VK_S", // 0x53 + "VK_T", // 0x54 + "VK_U", // 0x55 + "VK_V", // 0x56 + "VK_W", // 0x57 + "VK_X", // 0x58 + "VK_Y", // 0x59 + "VK_Z", // 0x5A + "VK_LWIN", // 0x5B + "VK_RWIN", // 0x5C + "VK_APPS", // 0x5D + "ERR", // 0x5E + "VK_SLEEP", // 0x5F + "VK_NUMPAD0", // 0x60 + "VK_NUMPAD1", // 0x61 + "VK_NUMPAD2", // 0x62 + "VK_NUMPAD3", // 0x63 + "VK_NUMPAD4", // 0x64 + "VK_NUMPAD5", // 0x65 + "VK_NUMPAD6", // 0x66 + "VK_NUMPAD7", // 0x67 + "VK_NUMPAD8", // 0x68 + "VK_NUMPAD9", // 0x69 + "VK_MULTIPLY", // 0x6A + "VK_ADD", // 0x6B + "VK_SEPARATOR", // 0x6C + "VK_SUBTRACT", // 0x6D + "VK_DECIMAL", // 0x6E + "VK_DIVIDE", // 0x6F + "VK_F1", // 0x70 + "VK_F2", // 0x71 + "VK_F3", // 0x72 + "VK_F4", // 0x73 + "VK_F5", // 0x74 + "VK_F6", // 0x75 + "VK_F7", // 0x76 + "VK_F8", // 0x77 + "VK_F9", // 0x78 + "VK_F10", // 0x79 + "VK_F11", // 0x7A + "VK_F12", // 0x7B + "VK_F13", // 0x7C + "VK_F14", // 0x7D + "VK_F15", // 0x7E + "VK_F16", // 0x7F + "VK_F17", // 0x80 + "VK_F18", // 0x81 + "VK_F19", // 0x82 + "VK_F20", // 0x83 + "VK_F21", // 0x84 + "VK_F22", // 0x85 + "VK_F23", // 0x86 + "VK_F24", // 0x87 + "ERR", // 0x88 + "ERR", // 0x89 + "ERR", // 0x8A + "ERR", // 0x8B + "ERR", // 0x8C + "ERR", // 0x8D + "ERR", // 0x8E + "ERR", // 0x8F + "VK_NUMLOCK", // 0x90 + "VK_SCROLL", // 0x91 + "ERR", // 0x92 + "ERR", // 0x93 + "ERR", // 0x94 + "ERR", // 0x95 + "ERR", // 0x96 + "ERR", // 0x97 + "ERR", // 0x98 + "ERR", // 0x99 + "ERR", // 0x9A + "ERR", // 0x9B + "ERR", // 0x9C + "ERR", // 0x9D + "ERR", // 0x9E + "ERR", // 0x9F + "VK_LSHIFT", // 0xA0 + "VK_RSHIFT", // 0xA1 + "VK_LCONTROL", // 0xA2 + "VK_RCONTROL", // 0xA3 + "VK_LMENU", // 0xA4 + "VK_RMENU", // 0xA5 + "VK_BROWSER_BACK", // 0xA6 + "VK_BROWSER_FORWARD", // 0xA7 + "VK_BROWSER_REFRESH", // 0xA8 + "VK_BROWSER_STOP", // 0xA9 + "VK_BROWSER_SEARCH", // 0xAA + "VK_BROWSER_FAVORITES", // 0xAB + "VK_BROWSER_HOME", // 0xAC + "VK_VOLUME_MUTE", // 0xAD + "VK_VOLUME_DOWN", // 0xAE + "VK_VOLUME_UP", // 0xAF + "VK_MEDIA_NEXT_TRACK", // 0xB0 + "VK_MEDIA_PREV_TRACK", // 0xB1 + "VK_MEDIA_STOP", // 0xB2 + "VK_MEDIA_PLAY_PAUSE", // 0xB3 + "VK_LAUNCH_MAIL", // 0xB4 + "VK_LAUNCH_MEDIA_SELECT", // 0xB5 + "VK_LAUNCH_APP1", // 0xB6 + "VK_LAUNCH_APP2", // 0xB7 + "ERR", // 0xB8 + "ERR", // 0xB9 + "VK_OEM_1", // 0xBA + "VK_OEM_PLUS", // 0xBB + "VK_OEM_COMMA", // 0xBC + "VK_OEM_MINUS", // 0xBD + "VK_OEM_PERIOD", // 0xBE + "VK_OEM_2", // 0xBF + "VK_OEM_3", // 0xC0 + "ERR", // 0xC1 + "ERR", // 0xC2 + "ERR", // 0xC3 + "ERR", // 0xC4 + "ERR", // 0xC5 + "ERR", // 0xC6 + "ERR", // 0xC7 + "ERR", // 0xC8 + "ERR", // 0xC9 + "ERR", // 0xCA + "ERR", // 0xCB + "ERR", // 0xCC + "ERR", // 0xCD + "ERR", // 0xCE + "ERR", // 0xCF + "ERR", // 0xD0 + "ERR", // 0xD1 + "ERR", // 0xD2 + "ERR", // 0xD3 + "ERR", // 0xD4 + "ERR", // 0xD5 + "ERR", // 0xD6 + "ERR", // 0xD7 + "ERR", // 0xD8 + "ERR", // 0xD9 + "ERR", // 0xDA + "VK_OEM_4", // 0xDB + "VK_OEM_5", // 0xDC + "VK_OEM_6", // 0xDD + "VK_OEM_7", // 0xDE + "VK_OEM_8", // 0xDF + "ERR", // 0xE0 + "ERR", // 0xE1 + "VK_OEM_102", // 0xE2 + "ERR", // 0xE3 + "ERR", // 0xE4 + "VK_PROCESSKEY", // 0xE5 + "ERR", // 0xE6 + "VK_PACKET", // 0xE7 + "ERR", // 0xE8 + "ERR", // 0xE9 + "ERR", // 0xEA + "ERR", // 0xEB + "ERR", // 0xEC + "ERR", // 0xED + "ERR", // 0xEE + "ERR", // 0xEF + "ERR", // 0xF0 + "ERR", // 0xF1 + "ERR", // 0xF2 + "ERR", // 0xF3 + "ERR", // 0xF4 + "ERR", // 0xF5 + "VK_ATTN", // 0xF6 + "VK_CRSEL", // 0xF7 + "VK_EXSEL", // 0xF8 + "VK_EREOF", // 0xF9 + "VK_PLAY", // 0xFA + "VK_ZOOM", // 0xFB + "VK_NONAME", // 0xFC + "VK_PA1", // 0xFD + "VK_OEM_CLEAR" // 0xFE +}; + +char* FormatKeyState(uint16_t state) { + + static char buffer[21]; + + buffer[0] = state & NUMLOCK_ON ? 'N' : 'n'; + buffer[1] = state & CAPSLOCK_ON ? 'C' : 'c'; + buffer[2] = state & SCROLLLOCK_ON ? 'S' : 's'; + buffer[3] = ' '; + + buffer[4] = state & ENHANCED_KEY ? 'E' : 'e'; + buffer[5] = ' '; + + buffer[6] = state & LEFT_ALT_PRESSED ? 'L' : 'l'; + buffer[7] = state & LEFT_ALT_PRESSED ? 'A' : 'a'; + buffer[8] = ' '; + + buffer[9] = state & LEFT_CTRL_PRESSED ? 'L' : 'l'; + buffer[10] = state & LEFT_CTRL_PRESSED ? 'C' : 'c'; + buffer[11] = ' '; + + buffer[12] = state & SHIFT_PRESSED ? 'S' : 's'; + buffer[13] = state & SHIFT_PRESSED ? 'H' : 'h'; + buffer[14] = ' '; + + buffer[15] = state & RIGHT_ALT_PRESSED ? 'R' : 'r'; + buffer[16] = state & RIGHT_ALT_PRESSED ? 'A' : 'a'; + buffer[17] = ' '; + + buffer[18] = state & RIGHT_CTRL_PRESSED ? 'R' : 'r'; + buffer[19] = state & RIGHT_CTRL_PRESSED ? 'C' : 'c'; + + buffer[20] = '\0'; + + return buffer; +} + + void ConsoleInput::Enqueue(const INPUT_RECORD *data, DWORD size) { if (size) { for (DWORD i = 0; i < size; ++i) { - if (data[i].EventType == KEY_EVENT) { - fprintf(stderr, "ConsoleInput::Enqueue: %lc %x %x %x %s\n", + if (data[i].EventType == KEY_EVENT) { + fprintf(stderr, "ConsoleInput::Enqueue: %s %s \"%lc\" %s, %x %x %x %x\n", + FormatKeyState(data[i].Event.KeyEvent.dwControlKeyState), + VirtualKeyNames[data[i].Event.KeyEvent.wVirtualKeyCode], data[i].Event.KeyEvent.uChar.UnicodeChar ? data[i].Event.KeyEvent.uChar.UnicodeChar : '#', - data[i].Event.KeyEvent.uChar.UnicodeChar, - data[i].Event.KeyEvent.wVirtualKeyCode, + data[i].Event.KeyEvent.bKeyDown ? "DOWN" : "UP", + data[i].Event.KeyEvent.dwControlKeyState, - data[i].Event.KeyEvent.bKeyDown ? "DOWN" : "UP"); + data[i].Event.KeyEvent.wVirtualKeyCode, + data[i].Event.KeyEvent.uChar.UnicodeChar, + + data[i].Event.KeyEvent.wVirtualScanCode + ); } } From 00bfefb68170ad60db8f50c1dc4aa8b936d8f193 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 1 Sep 2024 05:07:45 +0200 Subject: [PATCH 03/27] even better logging --- WinPort/src/Backend/WX/wxMain.cpp | 177 +++++++++++++++++++++++++++++- 1 file changed, 174 insertions(+), 3 deletions(-) diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp index 2f6755827..58fe22db9 100644 --- a/WinPort/src/Backend/WX/wxMain.cpp +++ b/WinPort/src/Backend/WX/wxMain.cpp @@ -1109,12 +1109,179 @@ static bool IsForcedCharTranslation(int code) || code==WXK_NUMPAD_MULTIPLY || code==WXK_NUMPAD_SUBTRACT || code==WXK_NUMPAD_DIVIDE); } +// helper function that returns textual description of wx virtual keycode +const char* GetWxVirtualKeyCodeName(int keycode) +{ + switch ( keycode ) + { +#define WXK_(x) \ + case WXK_##x: return #x; + + WXK_(BACK) + WXK_(TAB) + WXK_(RETURN) + WXK_(ESCAPE) + WXK_(SPACE) + WXK_(DELETE) + WXK_(START) + WXK_(LBUTTON) + WXK_(RBUTTON) + WXK_(CANCEL) + WXK_(MBUTTON) +// WXK_(NUMPAD_CENTER) + WXK_(SHIFT) + WXK_(ALT) + WXK_(CONTROL) + WXK_(MENU) + WXK_(PAUSE) + WXK_(CAPITAL) + WXK_(END) + WXK_(HOME) + WXK_(LEFT) + WXK_(UP) + WXK_(RIGHT) + WXK_(DOWN) + WXK_(SELECT) + WXK_(PRINT) + WXK_(EXECUTE) + WXK_(SNAPSHOT) + WXK_(INSERT) + WXK_(HELP) + WXK_(NUMPAD0) + WXK_(NUMPAD1) + WXK_(NUMPAD2) + WXK_(NUMPAD3) + WXK_(NUMPAD4) + WXK_(NUMPAD5) + WXK_(NUMPAD6) + WXK_(NUMPAD7) + WXK_(NUMPAD8) + WXK_(NUMPAD9) + WXK_(MULTIPLY) + WXK_(ADD) + WXK_(SEPARATOR) + WXK_(SUBTRACT) + WXK_(DECIMAL) + WXK_(DIVIDE) + WXK_(F1) + WXK_(F2) + WXK_(F3) + WXK_(F4) + WXK_(F5) + WXK_(F6) + WXK_(F7) + WXK_(F8) + WXK_(F9) + WXK_(F10) + WXK_(F11) + WXK_(F12) + WXK_(F13) + WXK_(F14) + WXK_(F15) + WXK_(F16) + WXK_(F17) + WXK_(F18) + WXK_(F19) + WXK_(F20) + WXK_(F21) + WXK_(F22) + WXK_(F23) + WXK_(F24) + WXK_(NUMLOCK) + WXK_(SCROLL) + WXK_(PAGEUP) + WXK_(PAGEDOWN) + WXK_(NUMPAD_SPACE) + WXK_(NUMPAD_TAB) + WXK_(NUMPAD_ENTER) + WXK_(NUMPAD_F1) + WXK_(NUMPAD_F2) + WXK_(NUMPAD_F3) + WXK_(NUMPAD_F4) + WXK_(NUMPAD_HOME) + WXK_(NUMPAD_LEFT) + WXK_(NUMPAD_UP) + WXK_(NUMPAD_RIGHT) + WXK_(NUMPAD_DOWN) + WXK_(NUMPAD_PAGEUP) + WXK_(NUMPAD_PAGEDOWN) + WXK_(NUMPAD_END) + WXK_(NUMPAD_INSERT) + WXK_(NUMPAD_DELETE) + WXK_(NUMPAD_EQUAL) + WXK_(NUMPAD_MULTIPLY) + WXK_(NUMPAD_ADD) + WXK_(NUMPAD_SEPARATOR) + WXK_(NUMPAD_SUBTRACT) + WXK_(NUMPAD_DECIMAL) + WXK_(NUMPAD_DIVIDE) + + WXK_(WINDOWS_LEFT) + WXK_(WINDOWS_RIGHT) +#ifdef __WXOSX__ + WXK_(RAW_CONTROL) +#endif + WXK_(BROWSER_BACK) + WXK_(BROWSER_FORWARD) + WXK_(BROWSER_REFRESH) + WXK_(BROWSER_STOP) + WXK_(BROWSER_SEARCH) + WXK_(BROWSER_FAVORITES) + WXK_(BROWSER_HOME) + WXK_(VOLUME_MUTE) + WXK_(VOLUME_DOWN) + WXK_(VOLUME_UP) + WXK_(MEDIA_NEXT_TRACK) + WXK_(MEDIA_PREV_TRACK) + WXK_(MEDIA_STOP) + WXK_(MEDIA_PLAY_PAUSE) + WXK_(LAUNCH_MAIL) + WXK_(LAUNCH_APP1) + WXK_(LAUNCH_APP2) + WXK_(LAUNCH_0) + WXK_(LAUNCH_1) + WXK_(LAUNCH_2) + WXK_(LAUNCH_3) + WXK_(LAUNCH_4) + WXK_(LAUNCH_5) + WXK_(LAUNCH_6) + WXK_(LAUNCH_7) + WXK_(LAUNCH_8) + WXK_(LAUNCH_9) + // skip A/B which are duplicate cases of APP1/2 + WXK_(LAUNCH_C) + WXK_(LAUNCH_D) + WXK_(LAUNCH_E) + WXK_(LAUNCH_F) +#undef WXK_ + + default: + return "ERR"; + } +} + +char* FormatWxKeyState(uint16_t state) { + + static char buffer[5]; + + buffer[0] = state & wxMOD_ALT ? 'A' : 'a'; + buffer[1] = state & wxMOD_CONTROL ? 'C' : 'c'; + buffer[2] = state & wxMOD_SHIFT ? 'S' : 's'; + buffer[3] = state & wxMOD_META ? 'M' : 'm'; + + buffer[4] = '\0'; + + return buffer; +} + void WinPortPanel::OnKeyDown( wxKeyEvent& event ) { ResetTimerIdling(); DWORD now = WINPORT(GetTickCount)(); const auto uni = event.GetUnicodeKey(); - fprintf(stderr, "\nOnKeyDown: raw=%x code=%x uni=%x (%lc) ts=%lu [now=%u]", + fprintf(stderr, "\nOnKeyDown: %s %s raw=%x code=%x uni=%x (%lc) ts=%lu [now=%u]", + FormatWxKeyState(event.GetModifiers()), + GetWxVirtualKeyCodeName(event.GetKeyCode()), event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp(), now); @@ -1233,7 +1400,9 @@ void WinPortPanel::OnKeyUp( wxKeyEvent& event ) { ResetTimerIdling(); const auto uni = event.GetUnicodeKey(); - fprintf(stderr, "\nOnKeyUp: raw=%x code=%x uni=%x (%lc) ts=%lu", + fprintf(stderr, "\nOnKeyUp: %s %s raw=%x code=%x uni=%x (%lc) ts=%lu", + FormatWxKeyState(event.GetModifiers()), + GetWxVirtualKeyCodeName(event.GetKeyCode()), event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp()); @@ -1314,7 +1483,9 @@ void WinPortPanel::OnChar( wxKeyEvent& event ) if (_key_tracker.LastKeydown().GetTimestamp() != event.GetTimestamp()) { fprintf(stderr, "\n"); } - fprintf(stderr, "OnChar: raw=%x code=%x uni=%x (%lc) ts=%lu lke=%u", + fprintf(stderr, "OnChar: %s %s raw=%x code=%x uni=%x (%lc) ts=%lu lke=%u", + FormatWxKeyState(event.GetModifiers()), + GetWxVirtualKeyCodeName(event.GetKeyCode()), event.GetRawKeyCode(), event.GetKeyCode(), uni, (uni > 0x1f) ? uni : L' ', event.GetTimestamp(), _last_keydown_enqueued); _exclusive_hotkeys.OnKeyUp(event); From 6abe6bed9b9947df0006d8a8d992e4a7e35cae2b Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 1 Sep 2024 06:08:44 +0200 Subject: [PATCH 04/27] try to fix build --- WinPort/src/Backend/WX/wxMain.cpp | 165 ------------------ WinPort/src/Backend/WX/wxWinTranslations.cpp | 169 ++++++++++++++++++- WinPort/src/Backend/WX/wxWinTranslations.h | 3 + 3 files changed, 170 insertions(+), 167 deletions(-) diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp index 58fe22db9..1a629eba4 100644 --- a/WinPort/src/Backend/WX/wxMain.cpp +++ b/WinPort/src/Backend/WX/wxMain.cpp @@ -1109,171 +1109,6 @@ static bool IsForcedCharTranslation(int code) || code==WXK_NUMPAD_MULTIPLY || code==WXK_NUMPAD_SUBTRACT || code==WXK_NUMPAD_DIVIDE); } -// helper function that returns textual description of wx virtual keycode -const char* GetWxVirtualKeyCodeName(int keycode) -{ - switch ( keycode ) - { -#define WXK_(x) \ - case WXK_##x: return #x; - - WXK_(BACK) - WXK_(TAB) - WXK_(RETURN) - WXK_(ESCAPE) - WXK_(SPACE) - WXK_(DELETE) - WXK_(START) - WXK_(LBUTTON) - WXK_(RBUTTON) - WXK_(CANCEL) - WXK_(MBUTTON) -// WXK_(NUMPAD_CENTER) - WXK_(SHIFT) - WXK_(ALT) - WXK_(CONTROL) - WXK_(MENU) - WXK_(PAUSE) - WXK_(CAPITAL) - WXK_(END) - WXK_(HOME) - WXK_(LEFT) - WXK_(UP) - WXK_(RIGHT) - WXK_(DOWN) - WXK_(SELECT) - WXK_(PRINT) - WXK_(EXECUTE) - WXK_(SNAPSHOT) - WXK_(INSERT) - WXK_(HELP) - WXK_(NUMPAD0) - WXK_(NUMPAD1) - WXK_(NUMPAD2) - WXK_(NUMPAD3) - WXK_(NUMPAD4) - WXK_(NUMPAD5) - WXK_(NUMPAD6) - WXK_(NUMPAD7) - WXK_(NUMPAD8) - WXK_(NUMPAD9) - WXK_(MULTIPLY) - WXK_(ADD) - WXK_(SEPARATOR) - WXK_(SUBTRACT) - WXK_(DECIMAL) - WXK_(DIVIDE) - WXK_(F1) - WXK_(F2) - WXK_(F3) - WXK_(F4) - WXK_(F5) - WXK_(F6) - WXK_(F7) - WXK_(F8) - WXK_(F9) - WXK_(F10) - WXK_(F11) - WXK_(F12) - WXK_(F13) - WXK_(F14) - WXK_(F15) - WXK_(F16) - WXK_(F17) - WXK_(F18) - WXK_(F19) - WXK_(F20) - WXK_(F21) - WXK_(F22) - WXK_(F23) - WXK_(F24) - WXK_(NUMLOCK) - WXK_(SCROLL) - WXK_(PAGEUP) - WXK_(PAGEDOWN) - WXK_(NUMPAD_SPACE) - WXK_(NUMPAD_TAB) - WXK_(NUMPAD_ENTER) - WXK_(NUMPAD_F1) - WXK_(NUMPAD_F2) - WXK_(NUMPAD_F3) - WXK_(NUMPAD_F4) - WXK_(NUMPAD_HOME) - WXK_(NUMPAD_LEFT) - WXK_(NUMPAD_UP) - WXK_(NUMPAD_RIGHT) - WXK_(NUMPAD_DOWN) - WXK_(NUMPAD_PAGEUP) - WXK_(NUMPAD_PAGEDOWN) - WXK_(NUMPAD_END) - WXK_(NUMPAD_INSERT) - WXK_(NUMPAD_DELETE) - WXK_(NUMPAD_EQUAL) - WXK_(NUMPAD_MULTIPLY) - WXK_(NUMPAD_ADD) - WXK_(NUMPAD_SEPARATOR) - WXK_(NUMPAD_SUBTRACT) - WXK_(NUMPAD_DECIMAL) - WXK_(NUMPAD_DIVIDE) - - WXK_(WINDOWS_LEFT) - WXK_(WINDOWS_RIGHT) -#ifdef __WXOSX__ - WXK_(RAW_CONTROL) -#endif - WXK_(BROWSER_BACK) - WXK_(BROWSER_FORWARD) - WXK_(BROWSER_REFRESH) - WXK_(BROWSER_STOP) - WXK_(BROWSER_SEARCH) - WXK_(BROWSER_FAVORITES) - WXK_(BROWSER_HOME) - WXK_(VOLUME_MUTE) - WXK_(VOLUME_DOWN) - WXK_(VOLUME_UP) - WXK_(MEDIA_NEXT_TRACK) - WXK_(MEDIA_PREV_TRACK) - WXK_(MEDIA_STOP) - WXK_(MEDIA_PLAY_PAUSE) - WXK_(LAUNCH_MAIL) - WXK_(LAUNCH_APP1) - WXK_(LAUNCH_APP2) - WXK_(LAUNCH_0) - WXK_(LAUNCH_1) - WXK_(LAUNCH_2) - WXK_(LAUNCH_3) - WXK_(LAUNCH_4) - WXK_(LAUNCH_5) - WXK_(LAUNCH_6) - WXK_(LAUNCH_7) - WXK_(LAUNCH_8) - WXK_(LAUNCH_9) - // skip A/B which are duplicate cases of APP1/2 - WXK_(LAUNCH_C) - WXK_(LAUNCH_D) - WXK_(LAUNCH_E) - WXK_(LAUNCH_F) -#undef WXK_ - - default: - return "ERR"; - } -} - -char* FormatWxKeyState(uint16_t state) { - - static char buffer[5]; - - buffer[0] = state & wxMOD_ALT ? 'A' : 'a'; - buffer[1] = state & wxMOD_CONTROL ? 'C' : 'c'; - buffer[2] = state & wxMOD_SHIFT ? 'S' : 's'; - buffer[3] = state & wxMOD_META ? 'M' : 'm'; - - buffer[4] = '\0'; - - return buffer; -} - void WinPortPanel::OnKeyDown( wxKeyEvent& event ) { ResetTimerIdling(); diff --git a/WinPort/src/Backend/WX/wxWinTranslations.cpp b/WinPort/src/Backend/WX/wxWinTranslations.cpp index 7a0f24ab5..bff1a3b22 100644 --- a/WinPort/src/Backend/WX/wxWinTranslations.cpp +++ b/WinPort/src/Backend/WX/wxWinTranslations.cpp @@ -256,8 +256,6 @@ static int IsEnhancedKey(int code, int code_raw) #endif ) return true; - return false; - #if defined (__WXGTK__) if (code_raw == RAW_ALTGR || code_raw == RAW_CONTEXT || code_raw == RAW_RCTRL) return true; #endif @@ -578,6 +576,9 @@ wx2INPUT_RECORD::wx2INPUT_RECORD(BOOL KeyDown, const wxKeyEvent& event, const Ke #if defined(wxHAS_RAW_KEY_CODES) && !defined(__WXMAC__) if (!event.GetKeyCode() && event.GetRawKeyCode() == RAW_CONTEXT) { + if (KeyDown) { + Event.KeyEvent.dwControlKeyState|= RIGHT_ALT_PRESSED; + } Event.KeyEvent.dwControlKeyState|= ENHANCED_KEY; Event.KeyEvent.wVirtualKeyCode = VK_MENU; } @@ -688,3 +689,167 @@ void WinPortWxAssertHandler(const wxString& file, int line, const wxString& func static_cast(msg.wc_str())); } +// helper function that returns textual description of wx virtual keycode +const char* GetWxVirtualKeyCodeName(int keycode) +{ + switch ( keycode ) + { +#define WXK_(x) \ + case WXK_##x: return #x; + + WXK_(BACK) + WXK_(TAB) + WXK_(RETURN) + WXK_(ESCAPE) + WXK_(SPACE) + WXK_(DELETE) + WXK_(START) + WXK_(LBUTTON) + WXK_(RBUTTON) + WXK_(CANCEL) + WXK_(MBUTTON) +// WXK_(NUMPAD_CENTER) + WXK_(SHIFT) + WXK_(ALT) + WXK_(CONTROL) + WXK_(MENU) + WXK_(PAUSE) + WXK_(CAPITAL) + WXK_(END) + WXK_(HOME) + WXK_(LEFT) + WXK_(UP) + WXK_(RIGHT) + WXK_(DOWN) + WXK_(SELECT) + WXK_(PRINT) + WXK_(EXECUTE) + WXK_(SNAPSHOT) + WXK_(INSERT) + WXK_(HELP) + WXK_(NUMPAD0) + WXK_(NUMPAD1) + WXK_(NUMPAD2) + WXK_(NUMPAD3) + WXK_(NUMPAD4) + WXK_(NUMPAD5) + WXK_(NUMPAD6) + WXK_(NUMPAD7) + WXK_(NUMPAD8) + WXK_(NUMPAD9) + WXK_(MULTIPLY) + WXK_(ADD) + WXK_(SEPARATOR) + WXK_(SUBTRACT) + WXK_(DECIMAL) + WXK_(DIVIDE) + WXK_(F1) + WXK_(F2) + WXK_(F3) + WXK_(F4) + WXK_(F5) + WXK_(F6) + WXK_(F7) + WXK_(F8) + WXK_(F9) + WXK_(F10) + WXK_(F11) + WXK_(F12) + WXK_(F13) + WXK_(F14) + WXK_(F15) + WXK_(F16) + WXK_(F17) + WXK_(F18) + WXK_(F19) + WXK_(F20) + WXK_(F21) + WXK_(F22) + WXK_(F23) + WXK_(F24) + WXK_(NUMLOCK) + WXK_(SCROLL) + WXK_(PAGEUP) + WXK_(PAGEDOWN) + WXK_(NUMPAD_SPACE) + WXK_(NUMPAD_TAB) + WXK_(NUMPAD_ENTER) + WXK_(NUMPAD_F1) + WXK_(NUMPAD_F2) + WXK_(NUMPAD_F3) + WXK_(NUMPAD_F4) + WXK_(NUMPAD_HOME) + WXK_(NUMPAD_LEFT) + WXK_(NUMPAD_UP) + WXK_(NUMPAD_RIGHT) + WXK_(NUMPAD_DOWN) + WXK_(NUMPAD_PAGEUP) + WXK_(NUMPAD_PAGEDOWN) + WXK_(NUMPAD_END) + WXK_(NUMPAD_INSERT) + WXK_(NUMPAD_DELETE) + WXK_(NUMPAD_EQUAL) + WXK_(NUMPAD_MULTIPLY) + WXK_(NUMPAD_ADD) + WXK_(NUMPAD_SEPARATOR) + WXK_(NUMPAD_SUBTRACT) + WXK_(NUMPAD_DECIMAL) + WXK_(NUMPAD_DIVIDE) + + WXK_(WINDOWS_LEFT) + WXK_(WINDOWS_RIGHT) +#ifdef __WXOSX__ + WXK_(RAW_CONTROL) +#endif + WXK_(BROWSER_BACK) + WXK_(BROWSER_FORWARD) + WXK_(BROWSER_REFRESH) + WXK_(BROWSER_STOP) + WXK_(BROWSER_SEARCH) + WXK_(BROWSER_FAVORITES) + WXK_(BROWSER_HOME) + WXK_(VOLUME_MUTE) + WXK_(VOLUME_DOWN) + WXK_(VOLUME_UP) + WXK_(MEDIA_NEXT_TRACK) + WXK_(MEDIA_PREV_TRACK) + WXK_(MEDIA_STOP) + WXK_(MEDIA_PLAY_PAUSE) + WXK_(LAUNCH_MAIL) + WXK_(LAUNCH_APP1) + WXK_(LAUNCH_APP2) + WXK_(LAUNCH_0) + WXK_(LAUNCH_1) + WXK_(LAUNCH_2) + WXK_(LAUNCH_3) + WXK_(LAUNCH_4) + WXK_(LAUNCH_5) + WXK_(LAUNCH_6) + WXK_(LAUNCH_7) + WXK_(LAUNCH_8) + WXK_(LAUNCH_9) + // skip A/B which are duplicate cases of APP1/2 + WXK_(LAUNCH_C) + WXK_(LAUNCH_D) + WXK_(LAUNCH_E) + WXK_(LAUNCH_F) +#undef WXK_ + + default: + return "ERR"; + } +} + +char* FormatWxKeyState(uint16_t state) { + + static char buffer[5]; + + buffer[0] = state & wxMOD_ALT ? 'A' : 'a'; + buffer[1] = state & wxMOD_CONTROL ? 'C' : 'c'; + buffer[2] = state & wxMOD_SHIFT ? 'S' : 's'; + buffer[3] = state & wxMOD_META ? 'M' : 'm'; + + buffer[4] = '\0'; + + return buffer; +} diff --git a/WinPort/src/Backend/WX/wxWinTranslations.h b/WinPort/src/Backend/WX/wxWinTranslations.h index 45c23b97b..640e9b0d5 100644 --- a/WinPort/src/Backend/WX/wxWinTranslations.h +++ b/WinPort/src/Backend/WX/wxWinTranslations.h @@ -55,3 +55,6 @@ WinPortRGB WxConsoleBackground2RGB(DWORD64 attributes); DWORD WxKeyboardLedsState(); void WinPortWxAssertHandler(const wxString& file, int line, const wxString& func, const wxString& cond, const wxString& msg); + +const char* GetWxVirtualKeyCodeName(int keycode); +char* FormatWxKeyState(uint16_t state); From 73b3eb819ba6b6de0845bf8ea5e4b0b94fb2be8d Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 1 Sep 2024 06:13:17 +0200 Subject: [PATCH 05/27] Revert "try to fix build" This reverts commit 6abe6bed9b9947df0006d8a8d992e4a7e35cae2b. --- WinPort/src/Backend/WX/wxMain.cpp | 165 ++++++++++++++++++ WinPort/src/Backend/WX/wxWinTranslations.cpp | 169 +------------------ WinPort/src/Backend/WX/wxWinTranslations.h | 3 - 3 files changed, 167 insertions(+), 170 deletions(-) diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp index 1a629eba4..58fe22db9 100644 --- a/WinPort/src/Backend/WX/wxMain.cpp +++ b/WinPort/src/Backend/WX/wxMain.cpp @@ -1109,6 +1109,171 @@ static bool IsForcedCharTranslation(int code) || code==WXK_NUMPAD_MULTIPLY || code==WXK_NUMPAD_SUBTRACT || code==WXK_NUMPAD_DIVIDE); } +// helper function that returns textual description of wx virtual keycode +const char* GetWxVirtualKeyCodeName(int keycode) +{ + switch ( keycode ) + { +#define WXK_(x) \ + case WXK_##x: return #x; + + WXK_(BACK) + WXK_(TAB) + WXK_(RETURN) + WXK_(ESCAPE) + WXK_(SPACE) + WXK_(DELETE) + WXK_(START) + WXK_(LBUTTON) + WXK_(RBUTTON) + WXK_(CANCEL) + WXK_(MBUTTON) +// WXK_(NUMPAD_CENTER) + WXK_(SHIFT) + WXK_(ALT) + WXK_(CONTROL) + WXK_(MENU) + WXK_(PAUSE) + WXK_(CAPITAL) + WXK_(END) + WXK_(HOME) + WXK_(LEFT) + WXK_(UP) + WXK_(RIGHT) + WXK_(DOWN) + WXK_(SELECT) + WXK_(PRINT) + WXK_(EXECUTE) + WXK_(SNAPSHOT) + WXK_(INSERT) + WXK_(HELP) + WXK_(NUMPAD0) + WXK_(NUMPAD1) + WXK_(NUMPAD2) + WXK_(NUMPAD3) + WXK_(NUMPAD4) + WXK_(NUMPAD5) + WXK_(NUMPAD6) + WXK_(NUMPAD7) + WXK_(NUMPAD8) + WXK_(NUMPAD9) + WXK_(MULTIPLY) + WXK_(ADD) + WXK_(SEPARATOR) + WXK_(SUBTRACT) + WXK_(DECIMAL) + WXK_(DIVIDE) + WXK_(F1) + WXK_(F2) + WXK_(F3) + WXK_(F4) + WXK_(F5) + WXK_(F6) + WXK_(F7) + WXK_(F8) + WXK_(F9) + WXK_(F10) + WXK_(F11) + WXK_(F12) + WXK_(F13) + WXK_(F14) + WXK_(F15) + WXK_(F16) + WXK_(F17) + WXK_(F18) + WXK_(F19) + WXK_(F20) + WXK_(F21) + WXK_(F22) + WXK_(F23) + WXK_(F24) + WXK_(NUMLOCK) + WXK_(SCROLL) + WXK_(PAGEUP) + WXK_(PAGEDOWN) + WXK_(NUMPAD_SPACE) + WXK_(NUMPAD_TAB) + WXK_(NUMPAD_ENTER) + WXK_(NUMPAD_F1) + WXK_(NUMPAD_F2) + WXK_(NUMPAD_F3) + WXK_(NUMPAD_F4) + WXK_(NUMPAD_HOME) + WXK_(NUMPAD_LEFT) + WXK_(NUMPAD_UP) + WXK_(NUMPAD_RIGHT) + WXK_(NUMPAD_DOWN) + WXK_(NUMPAD_PAGEUP) + WXK_(NUMPAD_PAGEDOWN) + WXK_(NUMPAD_END) + WXK_(NUMPAD_INSERT) + WXK_(NUMPAD_DELETE) + WXK_(NUMPAD_EQUAL) + WXK_(NUMPAD_MULTIPLY) + WXK_(NUMPAD_ADD) + WXK_(NUMPAD_SEPARATOR) + WXK_(NUMPAD_SUBTRACT) + WXK_(NUMPAD_DECIMAL) + WXK_(NUMPAD_DIVIDE) + + WXK_(WINDOWS_LEFT) + WXK_(WINDOWS_RIGHT) +#ifdef __WXOSX__ + WXK_(RAW_CONTROL) +#endif + WXK_(BROWSER_BACK) + WXK_(BROWSER_FORWARD) + WXK_(BROWSER_REFRESH) + WXK_(BROWSER_STOP) + WXK_(BROWSER_SEARCH) + WXK_(BROWSER_FAVORITES) + WXK_(BROWSER_HOME) + WXK_(VOLUME_MUTE) + WXK_(VOLUME_DOWN) + WXK_(VOLUME_UP) + WXK_(MEDIA_NEXT_TRACK) + WXK_(MEDIA_PREV_TRACK) + WXK_(MEDIA_STOP) + WXK_(MEDIA_PLAY_PAUSE) + WXK_(LAUNCH_MAIL) + WXK_(LAUNCH_APP1) + WXK_(LAUNCH_APP2) + WXK_(LAUNCH_0) + WXK_(LAUNCH_1) + WXK_(LAUNCH_2) + WXK_(LAUNCH_3) + WXK_(LAUNCH_4) + WXK_(LAUNCH_5) + WXK_(LAUNCH_6) + WXK_(LAUNCH_7) + WXK_(LAUNCH_8) + WXK_(LAUNCH_9) + // skip A/B which are duplicate cases of APP1/2 + WXK_(LAUNCH_C) + WXK_(LAUNCH_D) + WXK_(LAUNCH_E) + WXK_(LAUNCH_F) +#undef WXK_ + + default: + return "ERR"; + } +} + +char* FormatWxKeyState(uint16_t state) { + + static char buffer[5]; + + buffer[0] = state & wxMOD_ALT ? 'A' : 'a'; + buffer[1] = state & wxMOD_CONTROL ? 'C' : 'c'; + buffer[2] = state & wxMOD_SHIFT ? 'S' : 's'; + buffer[3] = state & wxMOD_META ? 'M' : 'm'; + + buffer[4] = '\0'; + + return buffer; +} + void WinPortPanel::OnKeyDown( wxKeyEvent& event ) { ResetTimerIdling(); diff --git a/WinPort/src/Backend/WX/wxWinTranslations.cpp b/WinPort/src/Backend/WX/wxWinTranslations.cpp index bff1a3b22..7a0f24ab5 100644 --- a/WinPort/src/Backend/WX/wxWinTranslations.cpp +++ b/WinPort/src/Backend/WX/wxWinTranslations.cpp @@ -256,6 +256,8 @@ static int IsEnhancedKey(int code, int code_raw) #endif ) return true; + return false; + #if defined (__WXGTK__) if (code_raw == RAW_ALTGR || code_raw == RAW_CONTEXT || code_raw == RAW_RCTRL) return true; #endif @@ -576,9 +578,6 @@ wx2INPUT_RECORD::wx2INPUT_RECORD(BOOL KeyDown, const wxKeyEvent& event, const Ke #if defined(wxHAS_RAW_KEY_CODES) && !defined(__WXMAC__) if (!event.GetKeyCode() && event.GetRawKeyCode() == RAW_CONTEXT) { - if (KeyDown) { - Event.KeyEvent.dwControlKeyState|= RIGHT_ALT_PRESSED; - } Event.KeyEvent.dwControlKeyState|= ENHANCED_KEY; Event.KeyEvent.wVirtualKeyCode = VK_MENU; } @@ -689,167 +688,3 @@ void WinPortWxAssertHandler(const wxString& file, int line, const wxString& func static_cast(msg.wc_str())); } -// helper function that returns textual description of wx virtual keycode -const char* GetWxVirtualKeyCodeName(int keycode) -{ - switch ( keycode ) - { -#define WXK_(x) \ - case WXK_##x: return #x; - - WXK_(BACK) - WXK_(TAB) - WXK_(RETURN) - WXK_(ESCAPE) - WXK_(SPACE) - WXK_(DELETE) - WXK_(START) - WXK_(LBUTTON) - WXK_(RBUTTON) - WXK_(CANCEL) - WXK_(MBUTTON) -// WXK_(NUMPAD_CENTER) - WXK_(SHIFT) - WXK_(ALT) - WXK_(CONTROL) - WXK_(MENU) - WXK_(PAUSE) - WXK_(CAPITAL) - WXK_(END) - WXK_(HOME) - WXK_(LEFT) - WXK_(UP) - WXK_(RIGHT) - WXK_(DOWN) - WXK_(SELECT) - WXK_(PRINT) - WXK_(EXECUTE) - WXK_(SNAPSHOT) - WXK_(INSERT) - WXK_(HELP) - WXK_(NUMPAD0) - WXK_(NUMPAD1) - WXK_(NUMPAD2) - WXK_(NUMPAD3) - WXK_(NUMPAD4) - WXK_(NUMPAD5) - WXK_(NUMPAD6) - WXK_(NUMPAD7) - WXK_(NUMPAD8) - WXK_(NUMPAD9) - WXK_(MULTIPLY) - WXK_(ADD) - WXK_(SEPARATOR) - WXK_(SUBTRACT) - WXK_(DECIMAL) - WXK_(DIVIDE) - WXK_(F1) - WXK_(F2) - WXK_(F3) - WXK_(F4) - WXK_(F5) - WXK_(F6) - WXK_(F7) - WXK_(F8) - WXK_(F9) - WXK_(F10) - WXK_(F11) - WXK_(F12) - WXK_(F13) - WXK_(F14) - WXK_(F15) - WXK_(F16) - WXK_(F17) - WXK_(F18) - WXK_(F19) - WXK_(F20) - WXK_(F21) - WXK_(F22) - WXK_(F23) - WXK_(F24) - WXK_(NUMLOCK) - WXK_(SCROLL) - WXK_(PAGEUP) - WXK_(PAGEDOWN) - WXK_(NUMPAD_SPACE) - WXK_(NUMPAD_TAB) - WXK_(NUMPAD_ENTER) - WXK_(NUMPAD_F1) - WXK_(NUMPAD_F2) - WXK_(NUMPAD_F3) - WXK_(NUMPAD_F4) - WXK_(NUMPAD_HOME) - WXK_(NUMPAD_LEFT) - WXK_(NUMPAD_UP) - WXK_(NUMPAD_RIGHT) - WXK_(NUMPAD_DOWN) - WXK_(NUMPAD_PAGEUP) - WXK_(NUMPAD_PAGEDOWN) - WXK_(NUMPAD_END) - WXK_(NUMPAD_INSERT) - WXK_(NUMPAD_DELETE) - WXK_(NUMPAD_EQUAL) - WXK_(NUMPAD_MULTIPLY) - WXK_(NUMPAD_ADD) - WXK_(NUMPAD_SEPARATOR) - WXK_(NUMPAD_SUBTRACT) - WXK_(NUMPAD_DECIMAL) - WXK_(NUMPAD_DIVIDE) - - WXK_(WINDOWS_LEFT) - WXK_(WINDOWS_RIGHT) -#ifdef __WXOSX__ - WXK_(RAW_CONTROL) -#endif - WXK_(BROWSER_BACK) - WXK_(BROWSER_FORWARD) - WXK_(BROWSER_REFRESH) - WXK_(BROWSER_STOP) - WXK_(BROWSER_SEARCH) - WXK_(BROWSER_FAVORITES) - WXK_(BROWSER_HOME) - WXK_(VOLUME_MUTE) - WXK_(VOLUME_DOWN) - WXK_(VOLUME_UP) - WXK_(MEDIA_NEXT_TRACK) - WXK_(MEDIA_PREV_TRACK) - WXK_(MEDIA_STOP) - WXK_(MEDIA_PLAY_PAUSE) - WXK_(LAUNCH_MAIL) - WXK_(LAUNCH_APP1) - WXK_(LAUNCH_APP2) - WXK_(LAUNCH_0) - WXK_(LAUNCH_1) - WXK_(LAUNCH_2) - WXK_(LAUNCH_3) - WXK_(LAUNCH_4) - WXK_(LAUNCH_5) - WXK_(LAUNCH_6) - WXK_(LAUNCH_7) - WXK_(LAUNCH_8) - WXK_(LAUNCH_9) - // skip A/B which are duplicate cases of APP1/2 - WXK_(LAUNCH_C) - WXK_(LAUNCH_D) - WXK_(LAUNCH_E) - WXK_(LAUNCH_F) -#undef WXK_ - - default: - return "ERR"; - } -} - -char* FormatWxKeyState(uint16_t state) { - - static char buffer[5]; - - buffer[0] = state & wxMOD_ALT ? 'A' : 'a'; - buffer[1] = state & wxMOD_CONTROL ? 'C' : 'c'; - buffer[2] = state & wxMOD_SHIFT ? 'S' : 's'; - buffer[3] = state & wxMOD_META ? 'M' : 'm'; - - buffer[4] = '\0'; - - return buffer; -} diff --git a/WinPort/src/Backend/WX/wxWinTranslations.h b/WinPort/src/Backend/WX/wxWinTranslations.h index 640e9b0d5..45c23b97b 100644 --- a/WinPort/src/Backend/WX/wxWinTranslations.h +++ b/WinPort/src/Backend/WX/wxWinTranslations.h @@ -55,6 +55,3 @@ WinPortRGB WxConsoleBackground2RGB(DWORD64 attributes); DWORD WxKeyboardLedsState(); void WinPortWxAssertHandler(const wxString& file, int line, const wxString& func, const wxString& cond, const wxString& msg); - -const char* GetWxVirtualKeyCodeName(int keycode); -char* FormatWxKeyState(uint16_t state); From 9a910ebf8f6b791199c5e134c5a1d0ae2c3b236c Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Sun, 1 Sep 2024 06:17:19 +0200 Subject: [PATCH 06/27] removed unused constants unsupported in older wx --- WinPort/src/Backend/WX/wxMain.cpp | 32 ------------------------------- 1 file changed, 32 deletions(-) diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp index 58fe22db9..3a7dc990c 100644 --- a/WinPort/src/Backend/WX/wxMain.cpp +++ b/WinPort/src/Backend/WX/wxMain.cpp @@ -1221,38 +1221,6 @@ const char* GetWxVirtualKeyCodeName(int keycode) #ifdef __WXOSX__ WXK_(RAW_CONTROL) #endif - WXK_(BROWSER_BACK) - WXK_(BROWSER_FORWARD) - WXK_(BROWSER_REFRESH) - WXK_(BROWSER_STOP) - WXK_(BROWSER_SEARCH) - WXK_(BROWSER_FAVORITES) - WXK_(BROWSER_HOME) - WXK_(VOLUME_MUTE) - WXK_(VOLUME_DOWN) - WXK_(VOLUME_UP) - WXK_(MEDIA_NEXT_TRACK) - WXK_(MEDIA_PREV_TRACK) - WXK_(MEDIA_STOP) - WXK_(MEDIA_PLAY_PAUSE) - WXK_(LAUNCH_MAIL) - WXK_(LAUNCH_APP1) - WXK_(LAUNCH_APP2) - WXK_(LAUNCH_0) - WXK_(LAUNCH_1) - WXK_(LAUNCH_2) - WXK_(LAUNCH_3) - WXK_(LAUNCH_4) - WXK_(LAUNCH_5) - WXK_(LAUNCH_6) - WXK_(LAUNCH_7) - WXK_(LAUNCH_8) - WXK_(LAUNCH_9) - // skip A/B which are duplicate cases of APP1/2 - WXK_(LAUNCH_C) - WXK_(LAUNCH_D) - WXK_(LAUNCH_E) - WXK_(LAUNCH_F) #undef WXK_ default: From 62264372149d8c07d1453b140069427605e7603e Mon Sep 17 00:00:00 2001 From: anta999 Date: Mon, 2 Sep 2024 15:06:41 +0400 Subject: [PATCH 07/27] annoing warnings removed --- far2l/src/base/array.hpp | 2 +- far2l/src/panels/filelist.cpp | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/far2l/src/base/array.hpp b/far2l/src/base/array.hpp index a87b1ff7b..c082db151 100644 --- a/far2l/src/base/array.hpp +++ b/far2l/src/base/array.hpp @@ -68,7 +68,7 @@ class TArray public: TArray(size_t Delta = 8); - TArray(const TArray &rhs); + TArray(const TArray &rhs); ~TArray() { Free(); } public: diff --git a/far2l/src/panels/filelist.cpp b/far2l/src/panels/filelist.cpp index 52b1cf739..0a4b415d9 100644 --- a/far2l/src/panels/filelist.cpp +++ b/far2l/src/panels/filelist.cpp @@ -4537,6 +4537,11 @@ const void *FileList::GetItem(int Index) void FileList::ClearAllItem() { + for (PrevDataItem **i = PrevDataList.First(); i; i = PrevDataList.Next(i)) { + (*i)->PrevListData.Clear(); //??? + } + +#if 0 // удалим пред.значение. if (!PrevDataList.Empty()) //??? { @@ -4544,5 +4549,7 @@ void FileList::ClearAllItem() i->PrevListData.Clear(); //??? } } +#endif + SymlinksCache.clear(); } From 04be0aa5600b5e8f80d130c56b5730d3e9f51fe9 Mon Sep 17 00:00:00 2001 From: anta999 Date: Mon, 2 Sep 2024 15:31:36 +0400 Subject: [PATCH 08/27] fix --- far2l/src/panels/filelist.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/far2l/src/panels/filelist.cpp b/far2l/src/panels/filelist.cpp index 0a4b415d9..e23e0b2d3 100644 --- a/far2l/src/panels/filelist.cpp +++ b/far2l/src/panels/filelist.cpp @@ -4537,7 +4537,7 @@ const void *FileList::GetItem(int Index) void FileList::ClearAllItem() { - for (PrevDataItem **i = PrevDataList.First(); i; i = PrevDataList.Next(i)) { + for (PrevDataItem **i = PrevDataList.Last(); i; i = PrevDataList.Prev(i)) { (*i)->PrevListData.Clear(); //??? } From 3f9ad81dc61f94936b02edf383334c3d2927b2f5 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Mon, 2 Sep 2024 19:33:56 +0200 Subject: [PATCH 09/27] cosmetic --- WinPort/src/ConsoleInput.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/WinPort/src/ConsoleInput.cpp b/WinPort/src/ConsoleInput.cpp index 41bf45d2b..2e7ff8dbd 100644 --- a/WinPort/src/ConsoleInput.cpp +++ b/WinPort/src/ConsoleInput.cpp @@ -300,7 +300,7 @@ void ConsoleInput::Enqueue(const INPUT_RECORD *data, DWORD size) { if (size) { for (DWORD i = 0; i < size; ++i) { - if (data[i].EventType == KEY_EVENT) { + if (data[i].EventType == KEY_EVENT) { fprintf(stderr, "ConsoleInput::Enqueue: %s %s \"%lc\" %s, %x %x %x %x\n", FormatKeyState(data[i].Event.KeyEvent.dwControlKeyState), VirtualKeyNames[data[i].Event.KeyEvent.wVirtualKeyCode], From 693d0edb328c9bb029c9131caaff5d9292d0d3a4 Mon Sep 17 00:00:00 2001 From: Ivan Sorokin Date: Mon, 2 Sep 2024 21:27:03 +0200 Subject: [PATCH 10/27] Fix #2370 --- far2l/src/vt/vtshell.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/far2l/src/vt/vtshell.cpp b/far2l/src/vt/vtshell.cpp index 849c16aeb..0549aa7b7 100644 --- a/far2l/src/vt/vtshell.cpp +++ b/far2l/src/vt/vtshell.cpp @@ -691,6 +691,12 @@ class VTShell : VTOutputReader::IProcessor, VTInputReader::IProcessor, IVTShell OnTerminalResized(); // window could resize during dialog box processing } + // remove "c;" prefix if any + size_t pos = str.rfind(';'); + if (pos != std::string::npos) { + str.erase(0, pos + 1); + } + std::vector plain; base64_decode(plain, str); { // release no more needed memory From 3b334ca28f1f625f94f1466602fd137474423094 Mon Sep 17 00:00:00 2001 From: akruphi <92621645+akruphi@users.noreply.github.com> Date: Mon, 2 Sep 2024 22:31:55 +0300 Subject: [PATCH 11/27] Prevent quick thoughtless tap Enter or Space or Esc in dialog --- far2l/src/vt/VTFar2lExtensios.cpp | 23 +++++++++++++---------- far2l/src/vt/vtshell.cpp | 20 ++++++++++++-------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/far2l/src/vt/VTFar2lExtensios.cpp b/far2l/src/vt/VTFar2lExtensios.cpp index 9cab336a3..cf9c03642 100644 --- a/far2l/src/vt/VTFar2lExtensios.cpp +++ b/far2l/src/vt/VTFar2lExtensios.cpp @@ -272,27 +272,30 @@ char VTFar2lExtensios::ClipboardAuthorize(std::string client_id) { SavedScreen saved_scr; ScrBuf.FillBuf(); - choice = Message(MSG_KEEPBACKGROUND, 4, - Msg::TerminalClipboardAccessTitle, - Msg::TerminalClipboardAccessText, - Msg::TerminalClipboardAccessBlock, // 0 - Msg::TerminalClipboardAccessTemporaryRemote, // 1 - Msg::TerminalClipboardAccessTemporaryLocal, // 2 - Msg::TerminalClipboardAccessAlwaysLocal); // 3 + do { // prevent quick thoughtless tap Enter or Space or Esc in dialog + choice = Message(MSG_KEEPBACKGROUND, 5, + Msg::TerminalClipboardAccessTitle, + Msg::TerminalClipboardAccessText, + L"...", // 0 - stub select for thoughtless tap + Msg::TerminalClipboardAccessBlock, // 1 + Msg::TerminalClipboardAccessTemporaryRemote, // 2 + Msg::TerminalClipboardAccessTemporaryLocal, // 3 + Msg::TerminalClipboardAccessAlwaysLocal); // 4 + } while( choice <= 0 ); } _vt_shell->OnTerminalResized(); // window could resize during dialog box processing switch (choice) { - case 3: // Always allow access to local clipboard + case 4: // Always allow access to local clipboard ListFileAppend(autheds_file, client_id); // fall through - case 2: // Temporary allow access to local clipboared + case 3: // Temporary allow access to local clipboared _autheds.insert(client_id); return 1; - case 1: // Tell client that he need to use own clipboard + case 2: // Tell client that he need to use own clipboard return -1; default: // Mimic just failed to open clipboard diff --git a/far2l/src/vt/vtshell.cpp b/far2l/src/vt/vtshell.cpp index 849c16aeb..616145972 100644 --- a/far2l/src/vt/vtshell.cpp +++ b/far2l/src/vt/vtshell.cpp @@ -675,16 +675,20 @@ class VTShell : VTOutputReader::IProcessor, VTInputReader::IProcessor, IVTShell std::lock_guard lock(_read_state_mutex); // stop input readout SavedScreen saved_scr; ScrBuf.FillBuf(); - auto choice = Message(MSG_KEEPBACKGROUND, 3, - Msg::TerminalClipboardAccessTitle, - Msg::TerminalClipboardSetText, - Msg::TerminalClipboardAccessBlock, // 0 - Msg::TerminalClipboardSetAllowOnce, // 1 - Msg::TerminalClipboardSetAllowForCommand); // 2 - if (choice != 1 && choice != 2) { + int choice; + do { // prevent quick thoughtless tap Enter or Space or Esc in dialog + choice = Message(MSG_KEEPBACKGROUND, 4, + Msg::TerminalClipboardAccessTitle, + Msg::TerminalClipboardSetText, + L"...", // 0 - stub select for thoughtless tap + Msg::TerminalClipboardAccessBlock, // 1 + Msg::TerminalClipboardSetAllowOnce, // 2 + Msg::TerminalClipboardSetAllowForCommand); // 3 + } while (choice <= 0 ); + if (choice != 2 && choice != 3) { return; } - if (choice == 2) { + if (choice == 3) { _allow_osc_clipset = true; } } From a24b7e470df817751b3e95ece68ffcf1bf041ac0 Mon Sep 17 00:00:00 2001 From: m32 Date: Sat, 7 Sep 2024 16:07:27 +0200 Subject: [PATCH 12/27] python build requirements --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f78265f4..bd5e9675c 100644 --- a/README.md +++ b/README.md @@ -172,7 +172,11 @@ To force-disable TTY|X and TTY|Xi backends: add argument `-DTTYX=no`; to disable To eliminate libuchardet requirement to reduce far2l dependencies by cost of losing automatic charset detection functionality: add `-DUSEUCD=no` -To build with Python plugin: add argument `-DPYTHON=yes` +To build with Python plugin: add argument `-DPYTHON=yes` but you must have installed additional packages within yours system: +libpython3-dev +libffi-dev +python3-venv + To control how RAR archives will be handled in multiarc: `-DUNRAR=bundled` (default) use bundled sources found in multiarc/src/formats/rar/unrar From f8dea93e0851c5ded2f0556b73eb41d299860732 Mon Sep 17 00:00:00 2001 From: anta999 Date: Sun, 8 Sep 2024 23:20:53 +0400 Subject: [PATCH 13/27] Align filenames by marks --- far2l/bootstrap/scripts/farlang.templ.m4 | 55 ++++++++++++++++++++ far2l/src/cfg/ConfigOpt.cpp | 6 +++ far2l/src/cfg/config.cpp | 25 +++++++++ far2l/src/cfg/config.hpp | 5 ++ far2l/src/console/interf.cpp | 14 +++++ far2l/src/console/interf.hpp | 2 + far2l/src/filefilterparams.cpp | 4 +- far2l/src/hilight.cpp | 65 ++++++++++++++++-------- far2l/src/hilight.hpp | 2 +- far2l/src/panels/filelist.cpp | 16 +++++- far2l/src/panels/filelist.hpp | 1 + far2l/src/panels/flshow.cpp | 19 +++++-- far2l/src/panels/flupdate.cpp | 11 ++-- far2l/src/setcolor.cpp | 1 - 14 files changed, 189 insertions(+), 37 deletions(-) diff --git a/far2l/bootstrap/scripts/farlang.templ.m4 b/far2l/bootstrap/scripts/farlang.templ.m4 index 7cbe9d174..23f1f8ecf 100644 --- a/far2l/bootstrap/scripts/farlang.templ.m4 +++ b/far2l/bootstrap/scripts/farlang.templ.m4 @@ -2022,6 +2022,61 @@ ConfigHighlight "&Розфарбовка файлів" "&Размалёўка файлаў" +ConfigFilenameMarks +"Показывать маркировку имен файлов" +"Show file name markings" +"Zobrazit označení názvů souborů" +"Dateinamenmarkierungen anzeigen" +"Fájlnevek megjelölésének megjelenítése" +"Pokaż oznaczenia nazw plików" +"Mostrar marcas de nombres de archivos" +"Показати маркування імен файлів" +"Паказаць маркіроўку імёнаў файлаў" + +ConfigFilenameMarksAlign +"Выравнивать имена файлов по маркировкам" +"Align file names by markings" +"Vyrovnat názvy souborů podle označení" +"Dateinamen nach Markierungen ausrichten" +"Fájlneveket igazítani a megjelölések szerint" +"Wyrównaj nazwy plików według oznaczeń" +"Alinear nombres de archivos por marcas" +"Вирівняти імена файлів за маркуваннями" +"Выраўнаваць імёны файлаў па маркіроўках" + +ConfigFilenameMinMaxIndentation +"Мин - макс отступ имен файлов" +"Min - max file names indentation" +"Min - max odsazení názvů souborů" +"Min - max Abstand von Dateinamen" +"Min - max fájlnevek behúzása" +"Min - maks wcięcie nazw plików" +"Sangrado mín - máx de nombres de archivos" +"Мін - макс відступ імен файлів" +"Мін - макс адступ імёнаў файлаў" + +ConfigFilenameMinIndentation +"Минимальный отступ имен файлов" +"Min file names indentation" +"Minimální odsazení názvů souborů" +"Minimal Abstand von Dateinamen" +"Minimális fájlnevek behúzása" +"Minimalne wcięcie nazw plików" +"Sangrado mínimo de nombres de archivos" +"Мінімальний відступ імен файлів" +"Мінімальны адступ імёнаў файлаў" + +ConfigFilenameMaxIndentation +"Максимальный отступ имен файлов" +"Max file names indentation" +"Maximální odsazení názvů souborů" +"Maximaler Abstand von Dateinamen" +"Maximális fájlnevek behúzása" +"Maksymalne wcięcie nazw plików" +"Sangrado Máximo de nombres de archivos" +"Максимальний відступ імен файлів" +"Максімальны адступ імёнаў файлаў" + ConfigAutoChange "&Автосмена папки" "&Auto change folder" diff --git a/far2l/src/cfg/ConfigOpt.cpp b/far2l/src/cfg/ConfigOpt.cpp index f9086d931..e659ff42f 100644 --- a/far2l/src/cfg/ConfigOpt.cpp +++ b/far2l/src/cfg/ConfigOpt.cpp @@ -71,6 +71,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pick_colorRGB.hpp" void SanitizeHistoryCounts(); +void SanitizeIndentationCounts(); static bool g_config_ready = false; @@ -385,6 +386,10 @@ const ConfigOpt g_cfg_opts[] { {false, NSecPanel, "CtrlAltShiftRule", &Opt.PanelCtrlAltShiftRule, 0}, {false, NSecPanel, "RememberLogicalDrives", &Opt.RememberLogicalDrives, 0}, {true, NSecPanel, "AutoUpdateLimit", &Opt.AutoUpdateLimit, 0}, + {true, NSecPanel, "ShowFilenameMarks", &Opt.ShowFilenameMarks, 1}, + {true, NSecPanel, "FilenameMarksAllign", &Opt.FilenameMarksAllign, 0}, + {true, NSecPanel, "MinFilenameIndentation", &Opt.MinFilenameIndentation, 0}, + {true, NSecPanel, "MaxFilenameIndentation", &Opt.MaxFilenameIndentation, HIGHLIGHT_MAX_MARK_LENGTH}, {true, NSecPanelLeft, "Type", &Opt.LeftPanel.Type, 0}, {true, NSecPanelLeft, "Visible", &Opt.LeftPanel.Visible, 1}, @@ -695,6 +700,7 @@ void ConfigOptLoad() /* <ПОСТПРОЦЕССЫ> *************************************************** */ SanitizeHistoryCounts(); + SanitizeIndentationCounts(); if (Opt.CursorBlinkTime < 100) Opt.CursorBlinkTime = 100; diff --git a/far2l/src/cfg/config.cpp b/far2l/src/cfg/config.cpp index 2ce58f11a..f25dcb11f 100644 --- a/far2l/src/cfg/config.cpp +++ b/far2l/src/cfg/config.cpp @@ -132,6 +132,14 @@ void SanitizeHistoryCounts() Opt.DialogsHistoryCount = std::max(Opt.DialogsHistoryCount, 16); } +void SanitizeIndentationCounts() +{ + if (Opt.MaxFilenameIndentation > HIGHLIGHT_MAX_MARK_LENGTH) + Opt.MaxFilenameIndentation = HIGHLIGHT_MAX_MARK_LENGTH; + if (Opt.MinFilenameIndentation > HIGHLIGHT_MAX_MARK_LENGTH) + Opt.MinFilenameIndentation = HIGHLIGHT_MAX_MARK_LENGTH; +} + void SystemSettings() { DialogBuilder Builder(Msg::ConfigSystemTitle, L"SystemSettings"); @@ -212,6 +220,21 @@ void PanelSettings() Builder.AddCheckbox(Msg::ConfigHidden, &Opt.ShowHidden); Builder.AddCheckbox(Msg::ConfigHighlight, &Opt.Highlight); + Builder.AddCheckbox(Msg::ConfigFilenameMarks, &Opt.ShowFilenameMarks); + Builder.AddCheckbox(Msg::ConfigFilenameMarksAlign, &Opt.FilenameMarksAllign); + + DialogItemEx *IndentationMinEdit = Builder.AddIntEditField(&Opt.MinFilenameIndentation, 2); + DialogItemEx *MinText = Builder.AddTextBefore(IndentationMinEdit, Msg::ConfigFilenameMinIndentation); + + IndentationMinEdit->Indent(4); + MinText->Indent(4); + + DialogItemEx *IndentationMaxEdit = Builder.AddIntEditField(&Opt.MaxFilenameIndentation, 2); + DialogItemEx *MaxText = Builder.AddTextBefore(IndentationMaxEdit, Msg::ConfigFilenameMaxIndentation); + + IndentationMaxEdit->Indent(4); + MaxText->Indent(4); + Builder.AddCheckbox(Msg::ConfigAutoChange, &Opt.Tree.AutoChangeFolder); Builder.AddCheckbox(Msg::ConfigSelectFolders, &Opt.SelectFolders); Builder.AddCheckbox(Msg::ConfigCaseSensitiveCompareSelect, &Opt.PanelCaseSensitiveCompareSelect); @@ -240,6 +263,8 @@ void PanelSettings() if (!AutoUpdate) Opt.AutoUpdateLimit = 0; + SanitizeIndentationCounts(); + // FrameManager->RefreshFrame(); CtrlObject->Cp()->LeftPanel->Update(UPDATE_KEEP_SELECTION); CtrlObject->Cp()->RightPanel->Update(UPDATE_KEEP_SELECTION); diff --git a/far2l/src/cfg/config.hpp b/far2l/src/cfg/config.hpp index 32e4cb937..1dac37edb 100644 --- a/far2l/src/cfg/config.hpp +++ b/far2l/src/cfg/config.hpp @@ -398,6 +398,11 @@ struct Options int InactivityExit; int InactivityExitTime; int ShowHidden; + + int ShowFilenameMarks; + int FilenameMarksAllign; + int MinFilenameIndentation, MaxFilenameIndentation; + int Highlight; int CursorBlinkTime; diff --git a/far2l/src/console/interf.cpp b/far2l/src/console/interf.cpp index 0e23d7b0c..07fe16b95 100644 --- a/far2l/src/console/interf.cpp +++ b/far2l/src/console/interf.cpp @@ -505,6 +505,20 @@ void Text(int X, int Y, uint64_t Color, const WCHAR *Str) Text(Str); } +void Text(const WCHAR Ch, uint64_t Color, size_t Length) +{ + if ( !Length ) + return; + + ScrBuf.FillRect(CurX, CurY, CurX + Length, CurY, Ch, Color); + CurX += Length; +} + +void Text(const WCHAR Ch, size_t Length) +{ + Text(Ch, CurColor, Length); +} + void Text(const WCHAR *Str, size_t Length) { if (Length == (size_t)-1) diff --git a/far2l/src/console/interf.hpp b/far2l/src/console/interf.hpp index 9b27f7ad0..180d46daa 100644 --- a/far2l/src/console/interf.hpp +++ b/far2l/src/console/interf.hpp @@ -86,6 +86,8 @@ void ScrollScreen(int Count); void Text(int X, int Y, uint64_t Color, const WCHAR *Str); void Text(int X, int Y, uint64_t Color, const WCHAR *Str, size_t Length); +void Text(const WCHAR Ch, uint64_t Color, size_t Length); +void Text(const WCHAR Ch, size_t Length); void Text(const WCHAR *Str, size_t Length = (size_t)-1); void TextEx(const WCHAR *Str, size_t Length = (size_t)-1); diff --git a/far2l/src/filefilterparams.cpp b/far2l/src/filefilterparams.cpp index 696593f64..9c5ad38e6 100644 --- a/far2l/src/filefilterparams.cpp +++ b/far2l/src/filefilterparams.cpp @@ -625,7 +625,6 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P static const DWORD FarColor[] = {COL_PANELTEXT, COL_PANELSELECTEDTEXT, COL_PANELCURSOR, COL_PANELSELECTEDCURSOR}; wchar_t VerticalLine0[] = {BoxSymbols[BS_V2], 0}; wchar_t VerticalLine1[] = {BoxSymbols[BS_V1], 0}; - static const wchar_t *wstrSpaces = L" "; union { SMALL_RECT drect; uint64_t i64drect; }; union { SMALL_RECT irect; uint64_t i64irect; }; @@ -673,7 +672,8 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P Text(x, y, ColorF, Msg::HighlightExample1, filenameexamplelen); x += filenameexamplelen; ColorF &= (0xFFFFFFFFFFFFFFFF ^ (COMMON_LVB_STRIKEOUT | COMMON_LVB_UNDERSCORE)); - Text(x, y, ColorF, wstrSpaces, freespace-ng); + Text(L' ', ColorF, freespace-ng); + x += (freespace - ng); Text(x, y, ColorB, VerticalLine1, 1); } diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index 9893a5e09..b7a71e858 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -470,31 +470,31 @@ class HighlightFilesChunk : protected Threaded uint64_t _CurrentTime; const TPointerArray &_HiData; FileListItem **_FileItem; - int _FileCount; + size_t _FileCount, _LongestMarkLength; bool _UseAttrHighlighting; virtual void *ThreadProc() { - DoNow(); - return nullptr; + return DoNow(); } public: HighlightFilesChunk(uint64_t CurrentTime, const TPointerArray &HiData, - FileListItem **FileItem, int FileCount, bool UseAttrHighlighting) + FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting) : _CurrentTime(CurrentTime), _HiData(HiData), _FileItem(FileItem), _FileCount(FileCount), + _LongestMarkLength(0), _UseAttrHighlighting(UseAttrHighlighting) {} virtual ~HighlightFilesChunk() { WaitThread(); } - void DoNow() + void *DoNow() { - for (int FCnt = 0; FCnt < _FileCount; ++FCnt) { + for (size_t FCnt = 0; FCnt < _FileCount; ++FCnt) { FileListItem &fli = *_FileItem[FCnt]; HighlightDataColor Colors = DefaultStartingColors; ApplyStartColors(&Colors); @@ -512,45 +512,66 @@ class HighlightFilesChunk : protected Threaded CurHiData->GetColors(&TempColors); ApplyColors(&Colors, &TempColors); - if (!CurHiData->GetContinueProcessing()) // || !HasTransparent(&fli->Colors)) + if (!CurHiData->GetContinueProcessing()) break; } } + + if (Colors.MarkLen > _LongestMarkLength) + _LongestMarkLength = Colors.MarkLen; + fli.ColorsPtr = PooledHighlightDataColor(Colors); } + + return (void *)_LongestMarkLength; } - void DoAsync() + void *GetResult() { return GetThreadResult(); } + + bool DoAsync() { - if (!StartThread()) { - DoNow(); - } + return StartThread(); } }; -void HighlightFiles::GetHiColor(FileListItem **FileItem, int FileCount, bool UseAttrHighlighting) +void HighlightFiles::GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *_LongestMarkLength) { if (!FileItem || !FileCount) return; + size_t LongestMarkLength = 0; + size_t BestThreadsNum = std::max(BestThreadsCount(), 1u); std::list async_hfc; const int sFileCountTrh = 0x1000; // empirically found, can be subject of (dynamic) adjustment - if (FileCount >= sFileCountTrh && BestThreadsCount() > 1) { - int FilePerCPU = std::max(FileCount / BestThreadsCount(), 0x400u); - while (FileCount > FilePerCPU && async_hfc.size() + 1 < BestThreadsCount()) { + if (FileCount >= sFileCountTrh && BestThreadsNum > 1) { + size_t FilePerCPU = std::max(FileCount / BestThreadsNum, (size_t)0x400u); + + while (FileCount > FilePerCPU && async_hfc.size() + 1 < BestThreadsNum) { async_hfc.emplace_back(CurrentTime, HiData, FileItem, FilePerCPU, UseAttrHighlighting); - async_hfc.back().DoAsync(); - FileItem+= FilePerCPU; - FileCount-= FilePerCPU; + if (!async_hfc.back().DoAsync()) { + async_hfc.pop_back(); + break; + } + FileItem += FilePerCPU; + FileCount -= FilePerCPU; } - // fprintf(stderr, "%s: spawned %u async processors %d files per each, %d files processed synchronously\n", - // __FUNCTION__, (unsigned int)async_hfc.size(), FilePerCPU, FileCount); } - HighlightFilesChunk(CurrentTime, HiData, FileItem, FileCount, UseAttrHighlighting).DoNow(); - // async_hfc will join at d-tors + size_t len = (size_t)HighlightFilesChunk(CurrentTime, HiData, FileItem, FileCount, UseAttrHighlighting).DoNow(); + if (len > LongestMarkLength) + LongestMarkLength = len; + + while(!async_hfc.empty( )) { + len = (size_t)async_hfc.back().GetResult(); + if (len > LongestMarkLength) + LongestMarkLength = len; + async_hfc.pop_back(); + } + + if (_LongestMarkLength && *_LongestMarkLength < LongestMarkLength ) + *_LongestMarkLength = LongestMarkLength; } int HighlightFiles::GetGroup(const FileListItem *fli) diff --git a/far2l/src/hilight.hpp b/far2l/src/hilight.hpp index 1c86e14dd..2990e8e14 100644 --- a/far2l/src/hilight.hpp +++ b/far2l/src/hilight.hpp @@ -84,7 +84,7 @@ class HighlightFiles public: void UpdateCurrentTime(); - void GetHiColor(FileListItem **FileItem, int FileCount, bool UseAttrHighlighting = false); + void GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *LongestMarkLength); int GetGroup(const FileListItem *fli); void HiEdit(int MenuPos); diff --git a/far2l/src/panels/filelist.cpp b/far2l/src/panels/filelist.cpp index e23e0b2d3..a9af36390 100644 --- a/far2l/src/panels/filelist.cpp +++ b/far2l/src/panels/filelist.cpp @@ -123,6 +123,7 @@ FileList::FileList() SelFileSize(0), TotalFileSize(0), FreeDiskSize(0), + LongestMarkLength(0), LastUpdateTime(0), Height(0), LeftPos(0), @@ -1222,6 +1223,14 @@ int FileList::ProcessKey(FarKey Key) RestoreSelection(); return TRUE; } + case KEY_CTRLM | KEY_ALT: { + Opt.ShowFilenameMarks ^= 1; + Redraw(); + Panel *AnotherPanel = CtrlObject->Cp()->GetAnotherPanel(this); + AnotherPanel->Update(UPDATE_KEEP_SELECTION); + AnotherPanel->Redraw(); + return TRUE; + } case KEY_CTRLR: { Update(UPDATE_KEEP_SELECTION | UPDATE_CAN_BE_ANNOYING); Redraw(); @@ -4537,8 +4546,11 @@ const void *FileList::GetItem(int Index) void FileList::ClearAllItem() { - for (PrevDataItem **i = PrevDataList.Last(); i; i = PrevDataList.Prev(i)) { - (*i)->PrevListData.Clear(); //??? + if (!PrevDataList.Empty()) //??? + { + for (PrevDataItem **i = PrevDataList.Last(); i; i = PrevDataList.Prev(i)) { + if (*i) (*i)->PrevListData.Clear(); //??? + } } #if 0 diff --git a/far2l/src/panels/filelist.hpp b/far2l/src/panels/filelist.hpp index 6e99b6c32..604b11ae2 100644 --- a/far2l/src/panels/filelist.hpp +++ b/far2l/src/panels/filelist.hpp @@ -194,6 +194,7 @@ class FileList : public Panel uint64_t SelFileSize; uint64_t TotalFileSize; uint64_t FreeDiskSize; + size_t LongestMarkLength; clock_t LastUpdateTime; int Height, Columns; std::deque _symlinks_backlog; diff --git a/far2l/src/panels/flshow.cpp b/far2l/src/panels/flshow.cpp index 1b499276d..93153d763 100644 --- a/far2l/src/panels/flshow.cpp +++ b/far2l/src/panels/flshow.cpp @@ -924,7 +924,6 @@ void FileList::ShowList(int ShowStatus, int StartColumn) GotoXY(CurX - 1, CurY); BoxText(CurX - 1 == X2 ? BoxSymbols[BS_V2] : L' '); } - continue; } @@ -967,18 +966,23 @@ void FileList::ShowList(int ShowStatus, int StartColumn) if ((ViewFlags & COLUMN_MARK) && Width > 2) { Text(ListData[ListPos]->Selected ? L"\x221A " : L" "); - Width-= 2; + Width -= 2; } + #if 1 - { // Draw mark str + if (Opt.ShowFilenameMarks && Opt.Highlight && Width > 2) { // Draw mark str const HighlightDataColor *const hl = ListData[ListPos]->ColorsPtr; - if ( Opt.Highlight && Width > 2 && hl->MarkLen ) { + int padlen = Opt.FilenameMarksAllign ? std::max((size_t)Opt.MinFilenameIndentation, LongestMarkLength) : Opt.MinFilenameIndentation; + if (padlen > Opt.MaxFilenameIndentation) + padlen = Opt.MaxFilenameIndentation; - const DWORD64 OldColor = GetColor(); + if ( hl->MarkLen ) { + const uint64_t OldColor = GetColor(); size_t ng = Width, outlen; outlen = StrSizeOfCells(hl->Mark, hl->MarkLen, ng, false); Width -= ng; + padlen -= ng; if (!ShowStatus) SetShowColor(ListPos, HIGHLIGHTCOLORTYPE_MARKSTR); @@ -986,6 +990,11 @@ void FileList::ShowList(int ShowStatus, int StartColumn) Text(hl->Mark, outlen); SetColor(OldColor); } + + if (padlen > 0) { + Width -= padlen; + Text(L' ', padlen); + } } #endif // SetColor64( color ); diff --git a/far2l/src/panels/flupdate.cpp b/far2l/src/panels/flupdate.cpp index fe49d8e75..ec86a2401 100644 --- a/far2l/src/panels/flupdate.cpp +++ b/far2l/src/panels/flupdate.cpp @@ -169,6 +169,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa TotalFileSize = 0; CacheSelIndex = -1; CacheSelClearIndex = -1; + LongestMarkLength = 0; if (Opt.ShowPanelFree) { uint64_t TotalSize, TotalFree; @@ -255,7 +256,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa if (!(fdata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) { if ((fdata.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) == 0 || Opt.ScanJunction) { - TotalFileSize+= NewPtr->FileSize; + TotalFileSize += NewPtr->FileSize; } } @@ -387,7 +388,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa } if (Opt.Highlight && !ListData.IsEmpty()) - CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count()); + CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count(), false, &LongestMarkLength); CreateChangeNotification(FALSE); CorrectPosition(); @@ -573,6 +574,8 @@ void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible) TotalFileSize = 0; CacheSelIndex = -1; CacheSelClearIndex = -1; + LongestMarkLength = 0; + strPluginDizName.Clear(); if (!ListData.IsEmpty()) { @@ -645,13 +648,13 @@ void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible) } if (!ListData.IsEmpty() && ((Info.Flags & OPIF_USEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING))) CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count(), - (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0); + (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &LongestMarkLength); if ((Info.Flags & OPIF_ADDDOTS) && !DotsPresent) { FileListItem *CurPtr = ListData.AddParentPoint(); if (CurPtr) { if ((Info.Flags & OPIF_USEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING)) - CtrlObject->HiFiles->GetHiColor(&CurPtr, 1, (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0); + CtrlObject->HiFiles->GetHiColor(&CurPtr, 1, (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &LongestMarkLength ); if (Info.HostFile && *Info.HostFile) { FAR_FIND_DATA_EX FindData; diff --git a/far2l/src/setcolor.cpp b/far2l/src/setcolor.cpp index f1271f277..dea78d45b 100644 --- a/far2l/src/setcolor.cpp +++ b/far2l/src/setcolor.cpp @@ -335,7 +335,6 @@ void SetColors() for(size_t i = 0; i < SIZE_ARRAY_PALETTE; i++) { Palette[i] = DefaultPalette8bit[i]; } - break; } From 487e3a394f7f126c2effdaed1d3cc73e93b22c7e Mon Sep 17 00:00:00 2001 From: anta999 Date: Sun, 8 Sep 2024 23:44:32 +0400 Subject: [PATCH 14/27] unsigned --- far2l/src/cfg/config.cpp | 4 ++-- far2l/src/cfg/config.hpp | 2 +- far2l/src/panels/flshow.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/far2l/src/cfg/config.cpp b/far2l/src/cfg/config.cpp index f25dcb11f..a08c6b7ab 100644 --- a/far2l/src/cfg/config.cpp +++ b/far2l/src/cfg/config.cpp @@ -223,13 +223,13 @@ void PanelSettings() Builder.AddCheckbox(Msg::ConfigFilenameMarks, &Opt.ShowFilenameMarks); Builder.AddCheckbox(Msg::ConfigFilenameMarksAlign, &Opt.FilenameMarksAllign); - DialogItemEx *IndentationMinEdit = Builder.AddIntEditField(&Opt.MinFilenameIndentation, 2); + DialogItemEx *IndentationMinEdit = Builder.AddIntEditField((int *)&Opt.MinFilenameIndentation, 2); DialogItemEx *MinText = Builder.AddTextBefore(IndentationMinEdit, Msg::ConfigFilenameMinIndentation); IndentationMinEdit->Indent(4); MinText->Indent(4); - DialogItemEx *IndentationMaxEdit = Builder.AddIntEditField(&Opt.MaxFilenameIndentation, 2); + DialogItemEx *IndentationMaxEdit = Builder.AddIntEditField((int *)&Opt.MaxFilenameIndentation, 2); DialogItemEx *MaxText = Builder.AddTextBefore(IndentationMaxEdit, Msg::ConfigFilenameMaxIndentation); IndentationMaxEdit->Indent(4); diff --git a/far2l/src/cfg/config.hpp b/far2l/src/cfg/config.hpp index 1dac37edb..c55bfa823 100644 --- a/far2l/src/cfg/config.hpp +++ b/far2l/src/cfg/config.hpp @@ -401,7 +401,7 @@ struct Options int ShowFilenameMarks; int FilenameMarksAllign; - int MinFilenameIndentation, MaxFilenameIndentation; + DWORD MinFilenameIndentation, MaxFilenameIndentation; int Highlight; int CursorBlinkTime; diff --git a/far2l/src/panels/flshow.cpp b/far2l/src/panels/flshow.cpp index 93153d763..e95e1b257 100644 --- a/far2l/src/panels/flshow.cpp +++ b/far2l/src/panels/flshow.cpp @@ -972,7 +972,7 @@ void FileList::ShowList(int ShowStatus, int StartColumn) #if 1 if (Opt.ShowFilenameMarks && Opt.Highlight && Width > 2) { // Draw mark str const HighlightDataColor *const hl = ListData[ListPos]->ColorsPtr; - int padlen = Opt.FilenameMarksAllign ? std::max((size_t)Opt.MinFilenameIndentation, LongestMarkLength) : Opt.MinFilenameIndentation; + uint32_t padlen = Opt.FilenameMarksAllign ? std::max((size_t)Opt.MinFilenameIndentation, LongestMarkLength) : Opt.MinFilenameIndentation; if (padlen > Opt.MaxFilenameIndentation) padlen = Opt.MaxFilenameIndentation; From 3d71720321c8e1e2cd8d09e4c9786ebeb409fdf7 Mon Sep 17 00:00:00 2001 From: akruphi <92621645+akruphi@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:44:56 +0300 Subject: [PATCH 15/27] Add bash-completion --- CMakeLists.txt | 1 + bash-completion/CMakeLists.txt | 4 ++++ bash-completion/far2l | 27 +++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 bash-completion/CMakeLists.txt create mode 100644 bash-completion/far2l diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a13f8b68..ff0dd1cc7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -536,6 +536,7 @@ endif() add_subdirectory (packaging) add_subdirectory(man) +add_subdirectory(bash-completion) if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") set(FIXUP_SCRIPT packaging/osx/FixupBundle.cmake) diff --git a/bash-completion/CMakeLists.txt b/bash-completion/CMakeLists.txt new file mode 100644 index 000000000..e773b594c --- /dev/null +++ b/bash-completion/CMakeLists.txt @@ -0,0 +1,4 @@ +if (NOT CMAKE_BASH_COMP_DIR) + set(CMAKE_BASH_COMP_DIR ${CMAKE_XDGDATA_DIR}/bash-completion/completions) +endif() +install(FILES far2l DESTINATION ${CMAKE_BASH_COMP_DIR}) diff --git a/bash-completion/far2l b/bash-completion/far2l new file mode 100644 index 000000000..897de91e2 --- /dev/null +++ b/bash-completion/far2l @@ -0,0 +1,27 @@ +# bash completion for far2l -*- shell-script -*- + +_far2l_completions() +{ + local cur prev words cword split + _init_completion -s || return + + case $prev in + -!(-*)[ev]) + _filedir + return + ;; + esac + + $split && return + + if [[ $cur == -* ]]; then + COMPREPLY=($(compgen -W '$(_parse_help "$1" -h)' -- "$cur")) + [[ ${COMPREPLY-} == *= ]] && compopt -o nospace + [[ ${COMPREPLY-} == *: ]] && compopt -o nospace + else + _filedir -d + fi +} && + complete -F _far2l_completions far2l + +# ex: filetype=sh From 0e85412cf6918351fbab0e59d5beefe8bd3cc331 Mon Sep 17 00:00:00 2001 From: akruphi <92621645+akruphi@users.noreply.github.com> Date: Tue, 10 Sep 2024 10:52:55 +0300 Subject: [PATCH 16/27] minor readme --- README.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index bd5e9675c..11af6809a 100644 --- a/README.md +++ b/README.md @@ -111,8 +111,11 @@ See also [Community packages & binaries](#community_bins) * `libnfs-dev` (_optional_ - needed for **NetRocks/NFS**) * `libneon27-dev` (or later, _optional_ - needed for **NetRocks/WebDAV**) * `libarchive-dev` (_optional_ - needed for better archives support in **multiarc**) -* `libunrar-dev` (_optional_ - needed for RAR archives support in **multiarc**, see UNRAR command line option) +* `libunrar-dev` (_optional_ - needed for RAR archives support in **multiarc**, see `UNRAR` command line option) * `libpcre3-dev` (or `libpcre2-dev` in older distributions, _optional_ - needed for advanced custom archive formats support in **multiarc**) +* `libpython3-dev` (_optional_ - needed for **python plugins** support, see `-DPYTHON` command line option) +* `libffi-dev` (_optional_ - needed for **python plugins** support, see `-DPYTHON` command line option) +* `python3-venv` (_optional_ - needed for **python plugins** support, see `-DPYTHON` command line option) * `cmake` ( >= 3.2.2 ) * `pkg-config` * `g++` @@ -172,10 +175,11 @@ To force-disable TTY|X and TTY|Xi backends: add argument `-DTTYX=no`; to disable To eliminate libuchardet requirement to reduce far2l dependencies by cost of losing automatic charset detection functionality: add `-DUSEUCD=no` -To build with Python plugin: add argument `-DPYTHON=yes` but you must have installed additional packages within yours system: -libpython3-dev -libffi-dev -python3-venv +To build with Python plugin: add argument `-DPYTHON=yes` +but you must have installed additional packages within yours system: +`libpython3-dev`, +`libffi-dev`, +`python3-venv`. To control how RAR archives will be handled in multiarc: From bec09b3a71486437e19dce67ac52e606c8ba2db1 Mon Sep 17 00:00:00 2001 From: anta999 Date: Tue, 10 Sep 2024 15:07:10 +0400 Subject: [PATCH 17/27] That's better --- far2l/bootstrap/scripts/farlang.templ.m4 | 18 ++++---- far2l/src/cfg/config.cpp | 10 ++-- far2l/src/panels/filelist.cpp | 11 ++++- far2l/src/panels/flshow.cpp | 58 ++++++++++-------------- 4 files changed, 47 insertions(+), 50 deletions(-) diff --git a/far2l/bootstrap/scripts/farlang.templ.m4 b/far2l/bootstrap/scripts/farlang.templ.m4 index 23f1f8ecf..86afeb42d 100644 --- a/far2l/bootstrap/scripts/farlang.templ.m4 +++ b/far2l/bootstrap/scripts/farlang.templ.m4 @@ -2056,15 +2056,15 @@ ConfigFilenameMinMaxIndentation "Мін - макс адступ імёнаў файлаў" ConfigFilenameMinIndentation -"Минимальный отступ имен файлов" -"Min file names indentation" -"Minimální odsazení názvů souborů" -"Minimal Abstand von Dateinamen" -"Minimális fájlnevek behúzása" -"Minimalne wcięcie nazw plików" -"Sangrado mínimo de nombres de archivos" -"Мінімальний відступ імен файлів" -"Мінімальны адступ імёнаў файлаў" +"Фиксированный отступ имен файлов" +"Fixed indentation of file names" +"Opravené odsazení názvů souborů" +"Festgelegte Einrückung von Dateinamen" +"A fájlnevek rögzített behúzása" +"Naprawione wcięcie nazw plików" +"Sangría fija de nombres de archivos" +"Виправлене відступлення імен файлів" +"Выпраўлены адступ імёнаў файлаў" ConfigFilenameMaxIndentation "Максимальный отступ имен файлов" diff --git a/far2l/src/cfg/config.cpp b/far2l/src/cfg/config.cpp index a08c6b7ab..d44fd03dc 100644 --- a/far2l/src/cfg/config.cpp +++ b/far2l/src/cfg/config.cpp @@ -221,17 +221,15 @@ void PanelSettings() Builder.AddCheckbox(Msg::ConfigHidden, &Opt.ShowHidden); Builder.AddCheckbox(Msg::ConfigHighlight, &Opt.Highlight); Builder.AddCheckbox(Msg::ConfigFilenameMarks, &Opt.ShowFilenameMarks); - Builder.AddCheckbox(Msg::ConfigFilenameMarksAlign, &Opt.FilenameMarksAllign); DialogItemEx *IndentationMinEdit = Builder.AddIntEditField((int *)&Opt.MinFilenameIndentation, 2); - DialogItemEx *MinText = Builder.AddTextBefore(IndentationMinEdit, Msg::ConfigFilenameMinIndentation); - - IndentationMinEdit->Indent(4); - MinText->Indent(4); + DialogItemEx *MinText = Builder.AddTextAfter(IndentationMinEdit, Msg::ConfigFilenameMinIndentation); + IndentationMinEdit->Indent(1); + MinText->Indent(1); + Builder.AddCheckbox(Msg::ConfigFilenameMarksAlign, &Opt.FilenameMarksAllign); DialogItemEx *IndentationMaxEdit = Builder.AddIntEditField((int *)&Opt.MaxFilenameIndentation, 2); DialogItemEx *MaxText = Builder.AddTextBefore(IndentationMaxEdit, Msg::ConfigFilenameMaxIndentation); - IndentationMaxEdit->Indent(4); MaxText->Indent(4); diff --git a/far2l/src/panels/filelist.cpp b/far2l/src/panels/filelist.cpp index a9af36390..2c85a507a 100644 --- a/far2l/src/panels/filelist.cpp +++ b/far2l/src/panels/filelist.cpp @@ -1224,7 +1224,16 @@ int FileList::ProcessKey(FarKey Key) return TRUE; } case KEY_CTRLM | KEY_ALT: { - Opt.ShowFilenameMarks ^= 1; + if (!Opt.ShowFilenameMarks) + Opt.ShowFilenameMarks ^= 1; + else { + if (!Opt.FilenameMarksAllign) + Opt.FilenameMarksAllign ^= 1; + else { + Opt.ShowFilenameMarks ^= 1; + Opt.FilenameMarksAllign ^= 1; + } + } Redraw(); Panel *AnotherPanel = CtrlObject->Cp()->GetAnotherPanel(this); AnotherPanel->Update(UPDATE_KEEP_SELECTION); diff --git a/far2l/src/panels/flshow.cpp b/far2l/src/panels/flshow.cpp index e95e1b257..6e2226aaa 100644 --- a/far2l/src/panels/flshow.cpp +++ b/far2l/src/panels/flshow.cpp @@ -867,7 +867,6 @@ void FileList::ShowList(int ShowStatus, int StartColumn) for (int I = Y1 + 1 + Opt.ShowColumnTitles, J = CurTopFile; I < Y2 - 2 * Opt.ShowPanelStatus; I++, J++) { int CurColumn = StartColumn; -// uint64_t color; if (ShowStatus) { SetFarColor(COL_PANELTEXT); @@ -877,25 +876,6 @@ void FileList::ShowList(int ShowStatus, int StartColumn) GotoXY(X1 + 1, I); } -// if (ShowStatus) { -// SetFarColor(COL_PANELTEXT); -// GotoXY(X1 + 1, Y2 - 1); -// } else { - -// uint64_t color = GetShowColor(J, HIGHLIGHTCOLORTYPE_FILE); -// if (ColumnType != NAME_COLUMN) -// SetColor64(color); - -// SetColor64( color & (0xFFFFFFFFFFFFFFFF ^ (COMMON_LVB_STRIKEOUT | COMMON_LVB_UNDERSCORE)) ); - -// GotoXY(X1 + 1, I); -// } - -// SetColor64(GetShowColor(Position, ColorType)); -// color &= (0xFFFFFFFFFFFFFFFF ^ (COMMON_LVB_STRIKEOUT | COMMON_LVB_UNDERSCORE)); - -///ColumnType != NAME_COLUMN - int StatusLine = FALSE; int Level = 1; @@ -935,8 +915,6 @@ void FileList::ShowList(int ShowStatus, int StartColumn) SetShowColor(ListPos); } - //uint64_t color = GetShowColor(ListPos, HIGHLIGHTCOLORTYPE_FILE); - if (!ShowStatus) SetShowColor(ListPos); @@ -968,21 +946,28 @@ void FileList::ShowList(int ShowStatus, int StartColumn) Text(ListData[ListPos]->Selected ? L"\x221A " : L" "); Width -= 2; } - #if 1 - if (Opt.ShowFilenameMarks && Opt.Highlight && Width > 2) { // Draw mark str + { /// Draw mark str + size_t padlen = std::min(Opt.MinFilenameIndentation, Opt.MaxFilenameIndentation); + + if (Opt.ShowFilenameMarks && Opt.Highlight ) { const HighlightDataColor *const hl = ListData[ListPos]->ColorsPtr; - uint32_t padlen = Opt.FilenameMarksAllign ? std::max((size_t)Opt.MinFilenameIndentation, LongestMarkLength) : Opt.MinFilenameIndentation; - if (padlen > Opt.MaxFilenameIndentation) - padlen = Opt.MaxFilenameIndentation; - if ( hl->MarkLen ) { + if (Opt.FilenameMarksAllign && LongestMarkLength > padlen) + padlen = std::min(LongestMarkLength, (size_t)Opt.MaxFilenameIndentation); + + if (hl->MarkLen && Width > 2) { const uint64_t OldColor = GetColor(); size_t ng = Width, outlen; outlen = StrSizeOfCells(hl->Mark, hl->MarkLen, ng, false); + ng = StrCellsCount( hl->Mark, outlen ); + Width -= ng; - padlen -= ng; + if (ng < padlen) + padlen -= ng; + else + padlen = 0; if (!ShowStatus) SetShowColor(ListPos, HIGHLIGHTCOLORTYPE_MARKSTR); @@ -990,15 +975,20 @@ void FileList::ShowList(int ShowStatus, int StartColumn) Text(hl->Mark, outlen); SetColor(OldColor); } + } - if (padlen > 0) { - Width -= padlen; - Text(L' ', padlen); + if (!ShowStatus && padlen && Width > 2) { + if (padlen > (size_t)Width) { + padlen = Width; + Width = 0; } + else + Width -= padlen; + + Text(L' ', padlen); } + } /// Draw mark str #endif -// SetColor64( color ); - const wchar_t *NamePtr = ListData[ListPos]->strName; const wchar_t *NameCopy = NamePtr; From f118a20f58aa7caa195f6e1dd80c4dab32889734 Mon Sep 17 00:00:00 2001 From: akruphi <92621645+akruphi@users.noreply.github.com> Date: Wed, 11 Sep 2024 09:26:35 +0300 Subject: [PATCH 18/27] readme add note --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 11af6809a..8e40155fb 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ emulators](#terminals), which provide clipboard access and has their advanced ke | Mode
(UI Backends) | TTY
(plain far2l) | TTY\|X | TTY\|Xi | GUI | | ---: | --- | --- | --- | --- | -| **Works:** | in terminal | in terminal | in terminal | in Desktop
environment
(X11
or Wayland
or macOS)
| +| **Works:** | in terminal | in terminal | in terminal | in Desktop
environment
(X11
or Wayland
or macOS)
via wxWidgets
| | **Binaries:** | far2l | far2l
far2l_ttyx.broker | far2l
far2l_ttyx.broker | far2l
far2l_gui.so | | **[Dependencies](#required-dependencies):** | minimal | + libx11 | + libx11, libxi | + wxWidgets, GTK | | **Keyboard:** | _Typical terminals_:
**only essential
key combinations**

_KiTTY_ (putty fork),
_kitty_ (*nix one),
_iTerm2_,
_Windows Terminal_,
far2l’s VT: **full support**
| _Typical terminals_:
**only essential
key combinations**

_KiTTY_ (putty fork),
_kitty_ (*nix one),
_iTerm2_,
_Windows Terminal_,
far2l’s VT: **full support**
| _Typical terminals_:
**most of key
combinations under x11**;
**only essential key
combinations
under Wayland**

_KiTTY_ (putty fork),
_kitty_ (*nix one),
_iTerm2_,
_Windows Terminal_,
far2l’s VT: **full support**
| **All key
combinations** | @@ -47,6 +47,16 @@ emulators](#terminals), which provide clipboard access and has their advanced ke | **Typical
use case:** | **Servers**,
embedded | Run far2l in
favorite terminal
but with
**better UX**
| Run far2l in
favorite terminal
but with
**best UX**
| **Desktop** | | **Mandatory:** | yes | no | no | no | +_Note_: When running far2l automatically downgrade +if its components are not installed (or system libs are not available): +**GUI** ⇒ **TTY|Xi** ⇒ **TTY|X** ⇒ **TTY**. +To force run only specific backend use in command line: +for **GUI**: `far2l --notty`; +for **TTY|Xi** use in command line: `far2l --tty`; +for **TTY|X**: `far2l --tty --nodetect=xi`; +for plain **TTY**: `far2l --tty --nodetect=x` +(see details via `far2l --help`). + _Note about use OSC 52 in TTY/TTY|X_: to interact with the system clipboard you must **not forget to enable OSC 52** in both the **FAR2L settings** (`Options`->`Interface settings`->`Use OSC52 to set clipboard data`, From 18478c9792809b0955d1051ee9d4aa66321b78af Mon Sep 17 00:00:00 2001 From: Aleksey Dobrunov Date: Thu, 12 Sep 2024 21:06:20 +0500 Subject: [PATCH 19/27] colorer: change logger library remove spdlog and fmt depends; use simple logger to stderr --- CMakeLists.txt | 4 - cmake/modules/FindSpdlog.cmake | 33 ----- cmake/modules/Findfmt.cmake | 46 ------- colorer/CMakeLists.txt | 53 +------- colorer/src/Colorer-library/README.md | 7 +- .../src/Colorer-library/src/CMakeLists.txt | 26 +--- .../src/Colorer-library/src/colorer/Common.h | 6 - .../src/colorer/common/Features.h.in | 5 - .../src/colorer/common/Logger.cpp | 28 ++++ .../src/colorer/common/Logger.h | 127 +++++++++++++++--- .../src/colorer/editor/BaseEditor.cpp | 16 +-- .../colorer/handlers/LineRegionsSupport.cpp | 2 +- .../src/colorer/handlers/StyledHRDMapper.cpp | 2 +- .../src/colorer/handlers/TextHRDMapper.cpp | 2 +- .../src/colorer/parsers/CatalogParser.cpp | 16 +-- .../src/colorer/parsers/FileTypeImpl.cpp | 2 +- .../src/colorer/parsers/HrcLibraryImpl.cpp | 120 ++++++++--------- .../src/colorer/parsers/ParserFactoryImpl.cpp | 20 +-- .../src/colorer/parsers/TextParserHelpers.cpp | 4 +- .../src/colorer/parsers/TextParserImpl.cpp | 28 ++-- .../src/colorer/strings/icu/Encodings.cpp | 2 +- .../src/colorer/strings/icu/UStr.cpp | 2 +- .../src/colorer/strings/icu/UnicodeLogger.h | 45 ------- .../src/colorer/strings/icu/common_icu.h | 2 +- .../src/colorer/strings/icu/strings.h | 3 - .../src/colorer/strings/legacy/UStr.cpp | 2 +- .../colorer/strings/legacy/UnicodeLogger.h | 44 ------ .../src/colorer/strings/legacy/strings.h | 4 - .../src/colorer/utils/Environment.cpp | 18 +-- .../src/colorer/xml/libxml2/LibXmlReader.cpp | 5 +- .../xml/xercesc/BaseEntityResolver.cpp | 2 +- .../xml/xercesc/XmlParserErrorHandler.cpp | 6 +- colorer/src/pcolorer2/CerrLogger.h | 56 ++++++++ colorer/src/pcolorer2/FarEditor.cpp | 2 +- colorer/src/pcolorer2/FarEditorSet.cpp | 16 +-- colorer/src/pcolorer2/pcolorer.cpp | 21 +-- 36 files changed, 343 insertions(+), 434 deletions(-) delete mode 100644 cmake/modules/FindSpdlog.cmake delete mode 100644 cmake/modules/Findfmt.cmake create mode 100644 colorer/src/Colorer-library/src/colorer/common/Logger.cpp delete mode 100644 colorer/src/Colorer-library/src/colorer/strings/icu/UnicodeLogger.h delete mode 100644 colorer/src/Colorer-library/src/colorer/strings/legacy/UnicodeLogger.h create mode 100644 colorer/src/pcolorer2/CerrLogger.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a13f8b68..495e0c8d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,10 +107,6 @@ if (NOT DEFINED UNRAR) set(UNRAR "bundled") endif() -if (NOT DEFINED USESPDLOG) - set(USESPDLOG "NO") -endif() - # EACP disabled by default for now as FAR's GetCodePageInfo rejects all multibyte charsets due to BUGBUG. # Uncomment EACP-stuff here when that will be fixed. See https://github.com/elfmz/far2l/issues/1179 #if (NOT DEFINED EACP) diff --git a/cmake/modules/FindSpdlog.cmake b/cmake/modules/FindSpdlog.cmake deleted file mode 100644 index 539726510..000000000 --- a/cmake/modules/FindSpdlog.cmake +++ /dev/null @@ -1,33 +0,0 @@ -# This module try to find spdlog lib -# Once done this will define -# -# Spdlog_FOUND - system has spdlog lib -# SPDLOG_INCLUDE_DIR - the spdlog include directory -# -# Available targets: -# Spdlog::Spdlog - -find_path(SPDLOG_INCLUDE_DIR spdlog/spdlog.h - PATHS - ENV SPDLOG_ROOT - ENV SPDLOG_INCLUDE_DIR - ${SPDLOG_ROOT} - /usr - /usr/local - $ENV{HOME}/.local - PATH_SUFFIXES - include - ) -mark_as_advanced(SPDLOG_INCLUDE_DIR) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(Spdlog - REQUIRED_VARS SPDLOG_INCLUDE_DIR - ) - -if(Spdlog_FOUND AND NOT TARGET Spdlog::Spdlog) - add_library(Spdlog::Spdlog INTERFACE IMPORTED) - set_target_properties(Spdlog::Spdlog PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${SPDLOG_INCLUDE_DIR}" - ) -endif() diff --git a/cmake/modules/Findfmt.cmake b/cmake/modules/Findfmt.cmake deleted file mode 100644 index 4b79f61ea..000000000 --- a/cmake/modules/Findfmt.cmake +++ /dev/null @@ -1,46 +0,0 @@ -find_path(fmt_INCLUDE_DIR NAMES fmt/format.h) - -if(fmt_INCLUDE_DIR) - set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/base.h") - if(NOT EXISTS "${_fmt_version_file}") - set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/core.h") - endif() - if(NOT EXISTS "${_fmt_version_file}") - set(_fmt_version_file "${fmt_INCLUDE_DIR}/fmt/format.h") - endif() - if(EXISTS "${_fmt_version_file}") - # parse "#define FMT_VERSION 40100" to 4.1.0 - file(STRINGS "${_fmt_version_file}" fmt_VERSION_LINE - REGEX "^#define[ \t]+FMT_VERSION[ \t]+[0-9]+$") - string(REGEX REPLACE "^#define[ \t]+FMT_VERSION[ \t]+([0-9]+)$" - "\\1" fmt_VERSION "${fmt_VERSION_LINE}") - foreach(ver "fmt_VERSION_PATCH" "fmt_VERSION_MINOR" "fmt_VERSION_MAJOR") - math(EXPR ${ver} "${fmt_VERSION} % 100") - math(EXPR fmt_VERSION "(${fmt_VERSION} - ${${ver}}) / 100") - endforeach() - set(fmt_VERSION - "${fmt_VERSION_MAJOR}.${fmt_VERSION_MINOR}.${fmt_VERSION_PATCH}") - endif() -endif() - -find_library(fmt_LIBRARY NAMES fmt) - -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(fmt - REQUIRED_VARS fmt_INCLUDE_DIR fmt_LIBRARY - VERSION_VAR fmt_VERSION) -mark_as_advanced( - fmt_INCLUDE_DIR - fmt_LIBRARY - fmt_VERSION_MAJOR - fmt_VERSION_MINOR - fmt_VERSION_PATCH - fmt_VERSION_STRING) - -if(fmt_FOUND AND NOT (TARGET fmt::fmt)) - add_library(fmt::fmt UNKNOWN IMPORTED) - set_target_properties(fmt::fmt PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${fmt_INCLUDE_DIR}" - IMPORTED_LINK_INTERFACE_LANGUAGES "CXX" - IMPORTED_LOCATION "${fmt_LIBRARY}") -endif() diff --git a/colorer/CMakeLists.txt b/colorer/CMakeLists.txt index b1a5e2c7b..a5a225bad 100644 --- a/colorer/CMakeLists.txt +++ b/colorer/CMakeLists.txt @@ -21,6 +21,7 @@ set(SOURCES src/pcolorer2/FarHrcSettings.cpp src/pcolorer2/pcolorer.cpp src/pcolorer2/tools.cpp + src/pcolorer2/CerrLogger.h ) # set options for colorer-library @@ -29,66 +30,15 @@ set(COLORER_USE_LIBXML ON) set(COLORER_BUILD_HARD_WARNINGS OFF) set(COLORER_BUILD_OLD_COMPILERS ON) -if (USESPDLOG) - FIND_PACKAGE(Spdlog REQUIRED) - set (SPDLOG_DEFINES - USESPDLOG - SPDLOG_DISABLE_TID_CACHING - SPDLOG_NO_THREAD_ID - SPDLOG_NO_TLS - ) - - if (NOT EXISTS "${SPDLOG_INCLUDE_DIR}/spdlog/fmt/bundled") - if (fmt_FOUND) - set (SPDLOG_DEFINES - ${SPDLOG_DEFINES} - SPDLOG_FMT_EXTERNAL=ON - ) - message("SPDLOG: using with SPDLOG_FMT_EXTERNAL cuz FMT installed but ${SPDLOG_INCLUDE_DIR}/spdlog/fmt/bundled is missing") - else() - message("SPDLOG: using without forced SPDLOG_FMT_EXTERNAL cuz FMT NOT installed") - endif() - else() - message("SPDLOG: using without forced SPDLOG_FMT_EXTERNAL cuz ${SPDLOG_INCLUDE_DIR}/spdlog/fmt/bundled exists") - endif() - set(COLORER_USE_DUMMY_LOGGER OFF) -else() - set(COLORER_USE_DUMMY_LOGGER ON) -endif() - - add_library(colorer MODULE ${SOURCES}) FIND_PACKAGE(LibXml2 REQUIRED) -# sometimes libstd requires linking to libfmt, sometimes not -# so, if libfmt there - lets link to it, if not - then dont care -FIND_PACKAGE(fmt) - -# using fmt_LIBRARY directrly target_link_libraries fails build -# so have to copy it into intermediate var but only if fmt_FOUND -if (fmt_FOUND) - set(fmt_LIBRARY_OPTIONAL "${fmt_LIBRARY}") - # add libfmt package into far2l dependencies if needed - IF(PACKAGE_DEPENDENCIES) - SET(PACKAGE_DEPENDENCIES "${PACKAGE_DEPENDENCIES}, libfmt${fmt_VERSION_MAJOR}" PARENT_SCOPE) - ELSE(PACKAGE_DEPENDENCIES) - SET(PACKAGE_DEPENDENCIES "libfmt${fmt_VERSION_MAJOR}" PARENT_SCOPE) - ENDIF(PACKAGE_DEPENDENCIES) -else() - set(fmt_LIBRARY_OPTIONAL "") -endif() - target_include_directories(colorer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/src/Colorer-library/src ) -if(USESPDLOG) - target_include_directories(colorer PUBLIC ${SPDLOG_INCLUDE_DIR}) -endif() - target_link_libraries(colorer - ${fmt_LIBRARY_OPTIONAL} utils colorer_lib far2l @@ -98,7 +48,6 @@ target_compile_definitions(colorer PUBLIC _UNICODE UNICODE __unix__ - ${SPDLOG_DEFINES} ) diff --git a/colorer/src/Colorer-library/README.md b/colorer/src/Colorer-library/README.md index a6180c609..4793d6ffb 100644 --- a/colorer/src/Colorer-library/README.md +++ b/colorer/src/Colorer-library/README.md @@ -46,7 +46,7 @@ You may build library on linux using standard package, without vcpkg. #### Ubuntu example ```bash -sudo apt install libicu-dev libxerces-c-dev libspdlog-dev libfmt-dev zlib1g-dev libminizip-dev libxml2-dev +sudo apt install libicu-dev libxerces-c-dev zlib1g-dev libminizip-dev libxml2-dev git clone https://github.com/colorer/Colorer-library.git cd Colorer-library mkdir _build @@ -57,7 +57,7 @@ cmake --build _build -j$(nproc --all) #### CentOS Example ```bash -sudo yum install libicu-devel xerces-c-devel spdlog-devel fmt-devel zlib-devel minizip1.2-devel +sudo yum install libicu-devel xerces-c-devel zlib-devel minizip1.2-devel git clone https://github.com/colorer/Colorer-library.git cd Colorer-library mkdir _build @@ -67,7 +67,7 @@ cmake --build _build -j$(nproc --all) ### MacOS ```bash -brew install xerces-c spdlog icu4c minizip ninja libxml2 +brew install xerces-c icu4c minizip ninja libxml2 git clone https://github.com/colorer/Colorer-library.git cd Colorer-library mkdir _build @@ -87,7 +87,6 @@ This options available for build * `COLORER_BUILD_HARD_WARNINGS` - Compiler warnings as error on Release build. Default 'ON'. * `COLORER_BUILD_OLD_COMPILERS` - Use own implementation for standard library. Default 'OFF'. * `COLORER_USE_ZIPINPUTSOURCE` - Enable the ability to work with schemes in zip archives. Default 'ON'. -* `COLORER_USE_DUMMY_LOGGER` - Use dummy logging. Default 'OFF'. * `COLORER_USE_DEEPTRACE` - Use trace logging. Default 'OFF'. * `COLORER_USE_ICU_STRINGS` - Use ICU library for strings. Default 'ON'. * `COLORER_USE_LIBXML` - Use LibXml2 library for parse xml, instead XercesC. Default 'OFF'. diff --git a/colorer/src/Colorer-library/src/CMakeLists.txt b/colorer/src/Colorer-library/src/CMakeLists.txt index 1264987d5..9f1eff67a 100644 --- a/colorer/src/Colorer-library/src/CMakeLists.txt +++ b/colorer/src/Colorer-library/src/CMakeLists.txt @@ -15,6 +15,7 @@ set(SRC_COLORER colorer/base/BaseNames.h colorer/base/XmlTagDefs.h colorer/common/Exception.cpp + colorer/common/Logger.cpp colorer/common/Logger.h colorer/cregexp/cregexp.cpp colorer/cregexp/cregexp.h @@ -141,9 +142,6 @@ if(COLORER_USE_ICU_STRINGS) colorer/strings/icu/UStr.cpp colorer/strings/icu/UStr.h ) - set(SRC_COLORER_SPDLOG - colorer/strings/icu/UnicodeLogger.h - ) set(COLORER_FEATURE_ICU 1) else() @@ -176,14 +174,6 @@ else() colorer/strings/legacy/x_tables.h colorer/strings/legacy/StringExceptions.h ) - set(SRC_COLORER_SPDLOG - colorer/strings/legacy/UnicodeLogger.h - ) -endif() - -if(COLORER_USE_DUMMY_LOGGER) - set(SRC_COLORER_SPDLOG) - set(COLORER_FEATURE_DUMMYLOGGER 1) endif() if(COLORER_BUILD_OLD_COMPILERS) @@ -242,7 +232,7 @@ set(MAIN_FLAGS_CXX_RELEASE ${FLAGS_CXX_RELEASE} ${FLAGS_CXX_DEFAULT}) #==================================================== # build #==================================================== -add_library(colorer_lib STATIC ${SRC_COLORER} ${SRC_COLORER_STRINGS} ${SRC_COLORER_XML} ${SRC_COLORER_ZIP} ${SRC_COLORER_SPDLOG} ${SRC_COLORER_PLATFORM}) +add_library(colorer_lib STATIC ${SRC_COLORER} ${SRC_COLORER_STRINGS} ${SRC_COLORER_XML} ${SRC_COLORER_ZIP} ${SRC_COLORER_PLATFORM}) add_library(colorer::colorer ALIAS colorer_lib) target_include_directories(colorer_lib PUBLIC "$" @@ -266,17 +256,15 @@ else() ) endif() - -if(NOT COLORER_USE_DUMMY_LOGGER) - target_link_libraries(colorer_lib - PUBLIC spdlog::spdlog - ) -endif() - if(COLORER_USE_ICU_STRINGS) target_link_libraries(colorer_lib PUBLIC ICU::uc ICU::data ) + if (APPLE) + target_include_directories(colorer_lib PUBLIC + "$" + ) + endif () endif() if(COLORER_USE_ZIPINPUTSOURCE) diff --git a/colorer/src/Colorer-library/src/colorer/Common.h b/colorer/src/Colorer-library/src/colorer/Common.h index b4c8dc4e5..92bd6834c 100644 --- a/colorer/src/Colorer-library/src/colorer/Common.h +++ b/colorer/src/Colorer-library/src/colorer/Common.h @@ -14,10 +14,4 @@ */ #include "colorer/common/Logger.h" -#ifdef COLORER_USE_DEEPTRACE -#define CTRACE(info) info -#else -#define CTRACE(info) -#endif - #endif // COLORER_COMMON_H diff --git a/colorer/src/Colorer-library/src/colorer/common/Features.h.in b/colorer/src/Colorer-library/src/colorer/common/Features.h.in index a280ddc28..f3a7dc094 100644 --- a/colorer/src/Colorer-library/src/colorer/common/Features.h.in +++ b/colorer/src/Colorer-library/src/colorer/common/Features.h.in @@ -9,11 +9,6 @@ */ #cmakedefine COLORER_FEATURE_ZIPINPUTSOURCE -/** - If defined, dummy logger is used. -*/ -#cmakedefine COLORER_FEATURE_DUMMYLOGGER - /** If defined, ICU strings is used. */ diff --git a/colorer/src/Colorer-library/src/colorer/common/Logger.cpp b/colorer/src/Colorer-library/src/colorer/common/Logger.cpp new file mode 100644 index 000000000..93ba00875 --- /dev/null +++ b/colorer/src/Colorer-library/src/colorer/common/Logger.cpp @@ -0,0 +1,28 @@ +#include "colorer/common/Logger.h" + +Logger* Log::logger = nullptr; + +void details::print_impl_inner(std::ostream& out, const std::string_view format, const size_t arg_count, const Argument** arguments) +{ + std::size_t a = 0; + + for (std::size_t i = 0, max = format.size(); i != max; ++i) { + switch (format[i]) { + case '%': + if (a == arg_count) { + throw std::invalid_argument {"Too few arguments"}; + } + arguments[a]->print(out); + ++a; + break; + case '\\': + ++i; + if (i == max) { + throw std::invalid_argument {"Invalid format string: stray \\ at end of string"}; + } + [[fallthrough]]; + default: + out << format[i]; + } + } +} \ No newline at end of file diff --git a/colorer/src/Colorer-library/src/colorer/common/Logger.h b/colorer/src/Colorer-library/src/colorer/common/Logger.h index adde4e42d..28d19034c 100644 --- a/colorer/src/Colorer-library/src/colorer/common/Logger.h +++ b/colorer/src/Colorer-library/src/colorer/common/Logger.h @@ -1,36 +1,123 @@ #ifndef COLORER_LOGGER_H #define COLORER_LOGGER_H +#include + +namespace details { + +class Argument +{ + public: + virtual void print(std::ostream& out) const = 0; + + protected: + ~Argument() = default; +}; + +void print_impl_inner(std::ostream& out, std::string_view format, size_t arg_count, const Argument** arguments); + +template +class ArgumentT final : public Argument +{ + public: + explicit ArgumentT(T const& t) : mData(t) {} + + void print(std::ostream& out) const override { out << mData; } + + private: + T const& mData; +}; + +template +ArgumentT make_argument(T const& t) +{ + return ArgumentT(t); +} + +template +void print_impl_outer(std::ostream& out, const std::string_view format, Args const&... args) +{ + constexpr size_t n = sizeof...(args); + Argument const* array[n + 1] = {static_cast(&args)...}; + print_impl_inner(out, format, n, array); +} + +} // namespace details + +template +void format_log_string(std::ostream& out, std::string_view format, Args&&... args) +{ + details::print_impl_outer(out, format, details::make_argument(std::forward(args))...); +} + #include "colorer/common/Features.h" +#ifdef COLORER_FEATURE_ICU -#ifndef COLORER_FEATURE_DUMMYLOGGER +#include "unicode/unistr.h" +namespace details { +template <> inline +void ArgumentT::print(std::ostream& out) const +{ + std::string result8; + mData.toUTF8String(result8); + out << result8; +} +} // namespace details +#else +#include "colorer/strings/legacy/strings.h" +namespace details { +template <> inline +void details::ArgumentT::print(std::ostream& out) const +{ + std::string const result8 = mData.getChars(); + out << result8; +} +} +#endif -#include +class Logger +{ + public: + enum LogLevel { LOG_OFF, LOG_ERROR, LOG_WARN, LOG_INFO, LOG_DEBUG, LOG_TRACE }; -extern std::shared_ptr logger; + virtual ~Logger() = default; + virtual void log(LogLevel level, const char* filename_in, int line_in, const char* funcname_in, + const char* message) = 0; +}; -#else // COLORER_FEATURE_DUMMYLOGGER -class DummyLogger +class Log { public: + + static void registerLogger(Logger& logger_) { logger = &logger_; } + template - void debug(Args... /*args*/) - { - } - template - void error(Args... /*args*/) - { - } - template - void warn(Args... /*args*/) - { - } - template - void trace(Args... /*args*/) + static void log(const Logger::LogLevel level, const char* filename_in, const int line_in, const char* funcname_in, + const std::string_view fmt, Args&&... args) { + if (logger != nullptr) { + std::stringstream buf; + format_log_string(buf, fmt, std::forward(args)...); + logger->log(level, filename_in, line_in, funcname_in, buf.str().c_str()); + } } + + private: + static Logger* logger; }; -extern std::shared_ptr logger; -#endif // COLORER_FEATURE_DUMMYLOGGER + +#define COLORER_LOGGER_PRINTF(level, ...) Log::log(level, __FILE__, __LINE__, static_cast(__FUNCTION__), __VA_ARGS__) +#define COLORER_LOG_ERROR(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_ERROR, __VA_ARGS__) +#define COLORER_LOG_WARN(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_WARN, __VA_ARGS__) +#define COLORER_LOG_INFO(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_INFO, __VA_ARGS__) +#define COLORER_LOG_DEBUG(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_DEBUG, __VA_ARGS__) +#define COLORER_LOG_TRACE(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_TRACE, __VA_ARGS__) + +#ifdef COLORER_USE_DEEPTRACE +#define COLORER_LOG_DEEPTRACE(...) COLORER_LOGGER_PRINTF(Logger::LogLevel::LOG_TRACE, __VA_ARGS__) +#else +#define COLORER_LOG_DEEPTRACE(...) +#endif + #endif // COLORER_LOGGER_H diff --git a/colorer/src/Colorer-library/src/colorer/editor/BaseEditor.cpp b/colorer/src/Colorer-library/src/colorer/editor/BaseEditor.cpp index d816e4ead..469e50d52 100644 --- a/colorer/src/Colorer-library/src/colorer/editor/BaseEditor.cpp +++ b/colorer/src/Colorer-library/src/colorer/editor/BaseEditor.cpp @@ -113,7 +113,7 @@ void BaseEditor::remapLRS(bool recreate) void BaseEditor::setFileType(FileType* ftype) { - logger->debug("[BaseEditor] setFileType: {0}", ftype->getName()); + COLORER_LOG_DEBUG("[BaseEditor] setFileType: %", ftype->getName()); currentFileType = ftype; parserFactory->getHrcLibrary().loadFileType(ftype); textParser->setFileType(currentFileType); @@ -329,7 +329,7 @@ LineRegion* BaseEditor::getLineRegions(int lno) void BaseEditor::modifyEvent(int topLine) { - logger->debug("[BaseEditor] modifyEvent: {0}", topLine); + COLORER_LOG_DEBUG("[BaseEditor] modifyEvent: %", topLine); if (invalidLine > topLine) { invalidLine = topLine; for (auto& editorListener : editorListeners) { @@ -347,14 +347,14 @@ void BaseEditor::modifyLineEvent(int line) void BaseEditor::visibleTextEvent(int wStart_, int wSize_) { - logger->debug("[BaseEditor] visibleTextEvent: {0}-{1}", wStart_, wSize_); + COLORER_LOG_DEBUG("[BaseEditor] visibleTextEvent: %-%", wStart_, wSize_); wStart = wStart_; wSize = wSize_; } void BaseEditor::lineCountEvent(int newLineCount) { - logger->debug("[BaseEditor] lineCountEvent: {0}", newLineCount); + COLORER_LOG_DEBUG("[BaseEditor] lineCountEvent: %", newLineCount); lineCount = newLineCount; } @@ -387,7 +387,7 @@ void BaseEditor::validate(int lno, bool rebuildRegions) lrSupport->clear(); // Regions were dropped layoutChanged = true; - logger->debug("[BaseEditor] lrSize != wSize*2"); + COLORER_LOG_DEBUG("[BaseEditor] lrSize != wSize*2"); } /* Fixes window position according to line number */ @@ -418,7 +418,7 @@ void BaseEditor::validate(int lno, bool rebuildRegions) } firstLine = newFirstLine; layoutChanged = true; - logger->debug("[BaseEditor] newFirstLine={0}, parseFrom={1}, parseTo={2}", firstLine, parseFrom, + COLORER_LOG_DEBUG("[BaseEditor] newFirstLine=%, parseFrom=%, parseTo=%", firstLine, parseFrom, parseTo); } @@ -442,14 +442,14 @@ void BaseEditor::validate(int lno, bool rebuildRegions) /* Runs parser */ if (parseTo - parseFrom > 0) { - logger->debug("[BaseEditor] validate:parse:{0}-{1}, {2}", parseFrom, parseTo, + COLORER_LOG_DEBUG("[BaseEditor] validate:parse:%-%, %", parseFrom, parseTo, tpmode == TextParser::TextParseMode::TPM_CACHE_READ ? "READ" : "UPDATE"); int stopLine = textParser->parse(parseFrom, parseTo - parseFrom, tpmode); if (tpmode == TextParser::TextParseMode::TPM_CACHE_UPDATE) { invalidLine = stopLine + 1; } - logger->debug("[BaseEditor] validate:parsed: invalidLine={0}", invalidLine); + COLORER_LOG_DEBUG("[BaseEditor] validate:parsed: invalidLine=%", invalidLine); } } diff --git a/colorer/src/Colorer-library/src/colorer/handlers/LineRegionsSupport.cpp b/colorer/src/Colorer-library/src/colorer/handlers/LineRegionsSupport.cpp index 626d0dc71..7d628be05 100644 --- a/colorer/src/Colorer-library/src/colorer/handlers/LineRegionsSupport.cpp +++ b/colorer/src/Colorer-library/src/colorer/handlers/LineRegionsSupport.cpp @@ -83,7 +83,7 @@ void LineRegionsSupport::setRegionMapper(const RegionMapper* rs) bool LineRegionsSupport::checkLine(size_t lno) const { if (lno < firstLineNo || lno >= firstLineNo + lineCount) { - logger->trace("[LineRegionsSupport] checkLine: line {0} out of range", lno); + COLORER_LOG_TRACE("[LineRegionsSupport] checkLine: line % out of range", lno); return false; } return true; diff --git a/colorer/src/Colorer-library/src/colorer/handlers/StyledHRDMapper.cpp b/colorer/src/Colorer-library/src/colorer/handlers/StyledHRDMapper.cpp index f06819d2d..9a0ca25de 100644 --- a/colorer/src/Colorer-library/src/colorer/handlers/StyledHRDMapper.cpp +++ b/colorer/src/Colorer-library/src/colorer/handlers/StyledHRDMapper.cpp @@ -30,7 +30,7 @@ void StyledHRDMapper::loadRegionMappings(XmlInputSource& is) auto rd_new = regionDefines.find(name); if (rd_new != regionDefines.end()) { - logger->warn("Duplicate region name '{0}' in file '{1}'. Previous value replaced.", name, is.getPath()); + COLORER_LOG_WARN("Duplicate region name '%' in file '%'. Previous value replaced.", name, is.getPath()); regionDefines.erase(rd_new); } diff --git a/colorer/src/Colorer-library/src/colorer/handlers/TextHRDMapper.cpp b/colorer/src/Colorer-library/src/colorer/handlers/TextHRDMapper.cpp index 41928f0ba..0dcc5f894 100644 --- a/colorer/src/Colorer-library/src/colorer/handlers/TextHRDMapper.cpp +++ b/colorer/src/Colorer-library/src/colorer/handlers/TextHRDMapper.cpp @@ -30,7 +30,7 @@ void TextHRDMapper::loadRegionMappings(XmlInputSource& is) auto tp = regionDefines.find(name); if (tp != regionDefines.end()) { - logger->warn("Duplicate region name '{0}' in file '{1}'. Previous value replaced.", name, is.getPath()); + COLORER_LOG_WARN("Duplicate region name '%' in file '%'. Previous value replaced.", name, is.getPath()); regionDefines.erase(tp); } std::shared_ptr stext; diff --git a/colorer/src/Colorer-library/src/colorer/parsers/CatalogParser.cpp b/colorer/src/Colorer-library/src/colorer/parsers/CatalogParser.cpp index 39e62ec5d..f3bdce869 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/CatalogParser.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/CatalogParser.cpp @@ -5,7 +5,7 @@ void CatalogParser::parse(const UnicodeString* path) { - logger->debug("start parse {0} as catalog.xml", *path); + COLORER_LOG_DEBUG("start parse % as catalog.xml", *path); hrc_locations.clear(); hrd_nodes.clear(); @@ -24,7 +24,7 @@ void CatalogParser::parse(const UnicodeString* path) parseCatalogBlock(*nodes.begin()); - logger->debug("end parse catalog.xml"); + COLORER_LOG_DEBUG("end parse catalog.xml"); } void CatalogParser::parseCatalogBlock(const XMLNode& elem) @@ -51,10 +51,10 @@ void CatalogParser::addHrcSetsLocation(const XMLNode& elem) const auto& attr_value = node.getAttrValue(catLocationAttrLink); if (!attr_value.isEmpty()) { hrc_locations.push_back(attr_value); - logger->debug("add hrc location: '{0}'", attr_value); + COLORER_LOG_DEBUG("add hrc location: '%'", attr_value); } else { - logger->warn("found hrc with empty location. skip it location."); + COLORER_LOG_WARN("found hrc with empty location. skip it location."); } } } @@ -78,7 +78,7 @@ std::unique_ptr CatalogParser::parseHRDSetsChild(const XMLNode& elem) const auto& xhrd_name = elem.getAttrValue(catHrdAttrName); if (xhrd_class.isEmpty() || xhrd_name.isEmpty()) { - logger->warn("found HRD with empty class/name. skip this record."); + COLORER_LOG_WARN("found HRD with empty class/name. skip this record."); return nullptr; } @@ -93,11 +93,11 @@ std::unique_ptr CatalogParser::parseHRDSetsChild(const XMLNode& elem) auto attr_value = node.getAttrValue(catLocationAttrLink); if (!attr_value.isEmpty()) { hrd_node->hrd_location.emplace_back(attr_value); - logger->debug("add hrd location '{0}' for {1}:{2}", hrd_node->hrd_location.back(), hrd_node->hrd_class, + COLORER_LOG_DEBUG("add hrd location '%' for %:%", hrd_node->hrd_location.back(), hrd_node->hrd_class, hrd_node->hrd_name); } else { - logger->warn("found hrd with empty location. skip it location."); + COLORER_LOG_WARN("found hrd with empty location. skip it location."); } } } @@ -105,6 +105,6 @@ std::unique_ptr CatalogParser::parseHRDSetsChild(const XMLNode& elem) if (!hrd_node->hrd_location.empty()) { return hrd_node; } - logger->warn("skip HRD {0}:{1} - not found valid location", hrd_node->hrd_class, hrd_node->hrd_name); + COLORER_LOG_WARN("skip HRD %:% - not found valid location", hrd_node->hrd_class, hrd_node->hrd_name); return nullptr; } diff --git a/colorer/src/Colorer-library/src/colorer/parsers/FileTypeImpl.cpp b/colorer/src/Colorer-library/src/colorer/parsers/FileTypeImpl.cpp index cdfd2e8aa..4eaef26ca 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/FileTypeImpl.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/FileTypeImpl.cpp @@ -82,7 +82,7 @@ int FileType::Impl::getParamValueInt(const UnicodeString& param_name, int def) c try { val = std::stoi(param_str, nullptr); } catch (std::exception&) { - logger->error("Error parse param {0} with value {1} to integer number", param_name, + COLORER_LOG_ERROR("Error parse param % with value % to integer number", param_name, param_str); } } diff --git a/colorer/src/Colorer-library/src/colorer/parsers/HrcLibraryImpl.cpp b/colorer/src/Colorer-library/src/colorer/parsers/HrcLibraryImpl.cpp index 5d50a561f..5571f927d 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/HrcLibraryImpl.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/HrcLibraryImpl.cpp @@ -88,16 +88,16 @@ void HrcLibrary::Impl::loadFileType(FileType* filetype) try { loadSource(input_source.get()); } catch (InputSourceException& e) { - logger->error("Can't open source stream: {0}", e.what()); + COLORER_LOG_ERROR("Can't open source stream: %", e.what()); thisType->pimpl->load_broken = true; } catch (HrcLibraryException& e) { - logger->error("{0} [{1}]", e.what(), thisType->pimpl->inputSource ? input_source->getPath() : ""); + COLORER_LOG_ERROR("% [%]", e.what(), thisType->pimpl->inputSource ? input_source->getPath() : ""); thisType->pimpl->load_broken = true; } catch (Exception& e) { - logger->error("{0} [{1}]", e.what(), thisType->pimpl->inputSource ? input_source->getPath() : ""); + COLORER_LOG_ERROR("% [%]", e.what(), thisType->pimpl->inputSource ? input_source->getPath() : ""); thisType->pimpl->load_broken = true; } catch (...) { - logger->error("Unknown exception while loading {0}", input_source->getPath()); + COLORER_LOG_ERROR("Unknown exception while loading %", input_source->getPath()); thisType->pimpl->load_broken = true; } @@ -177,7 +177,7 @@ const Region* HrcLibrary::Impl::getRegion(const UnicodeString* name) void HrcLibrary::Impl::parseHRC(const XmlInputSource& is) { - logger->debug("begin parse '{0}'", is.getPath()); + COLORER_LOG_DEBUG("begin parse '%'", is.getPath()); XmlReader xml(is); if (!xml.parse()) { @@ -205,7 +205,7 @@ void HrcLibrary::Impl::parseHRC(const XmlInputSource& is) updateStarted = false; } - logger->debug("end parse '{0}'", is.getPath()); + COLORER_LOG_DEBUG("end parse '%'", is.getPath()); } void HrcLibrary::Impl::parseHrcBlock(const XMLNode& elem) @@ -221,7 +221,7 @@ void HrcLibrary::Impl::parseHrcBlock(const XMLNode& elem) // not read annotation } else { - logger->warn("Unused element '{0}'. Current file {1}.", node.name, current_input_source->getPath()); + COLORER_LOG_WARN("Unused element '%'. Current file %.", node.name, current_input_source->getPath()); } } } @@ -231,14 +231,14 @@ void HrcLibrary::Impl::addPrototype(const XMLNode& elem) auto typeName = elem.getAttrValue(hrcPrototypeAttrName); if (typeName.isEmpty()) { - logger->error("Found unnamed prototype/package. Skipped."); + COLORER_LOG_ERROR("Found unnamed prototype/package. Skipped."); return; } auto ft = fileTypeHash.find(typeName); if (ft != fileTypeHash.end()) { unloadFileType(ft->second); - logger->warn("Duplicate prototype '{0}'. First version unloaded, current is loading.", typeName); + COLORER_LOG_WARN("Duplicate prototype '%'. First version unloaded, current is loading.", typeName); } const auto& typeGroup = elem.getAttrValue(hrcPrototypeAttrGroup); @@ -277,7 +277,7 @@ void HrcLibrary::Impl::parsePrototypeBlock(const XMLNode& elem, FileType* curren // not read annotation } else { - logger->warn("Unused element '{0}' in prototype '{1}'. Current file {2}.", node.name, + COLORER_LOG_WARN("Unused element '%' in prototype '%'. Current file %.", node.name, current_parse_prototype->pimpl->name, current_input_source->getPath()); } } @@ -287,7 +287,7 @@ void HrcLibrary::Impl::addPrototypeLocation(const XMLNode& elem, FileType* curre { const auto& locationLink = elem.getAttrValue(hrcLocationAttrLink); if (locationLink.isEmpty()) { - logger->error("Bad 'location' link attribute in prototype '{0}'", current_parse_prototype->pimpl->name); + COLORER_LOG_ERROR("Bad 'location' link attribute in prototype '%'", current_parse_prototype->pimpl->name); return; } current_parse_prototype->pimpl->inputSource = current_input_source->createRelative(locationLink); @@ -296,14 +296,14 @@ void HrcLibrary::Impl::addPrototypeLocation(const XMLNode& elem, FileType* curre void HrcLibrary::Impl::addPrototypeDetectParam(const XMLNode& elem, FileType* current_parse_prototype) { if (elem.text.isEmpty()) { - logger->warn("Bad '{0}' element in prototype '{1}'", elem.name, current_parse_prototype->pimpl->name); + COLORER_LOG_WARN("Bad '%' element in prototype '%'", elem.name, current_parse_prototype->pimpl->name); return; } auto matchRE = std::make_unique(&elem.text); matchRE->setPositionMoves(true); if (!matchRE->isOk()) { - logger->warn("Fault compiling chooser RE '{0}' in prototype '{1}'", elem.text, + COLORER_LOG_WARN("Fault compiling chooser RE '%' in prototype '%'", elem.text, current_parse_prototype->pimpl->name); return; } @@ -315,18 +315,18 @@ void HrcLibrary::Impl::addPrototypeDetectParam(const XMLNode& elem, FileType* cu try { double d = std::stod(UStr::to_stdstr(&weight)); if (d < 0) { - logger->warn( - "Weight must be greater than 0. Current value {0}. Default value will be used. Current " - "file {1}.", + COLORER_LOG_WARN( + "Weight must be greater than 0. Current value %. Default value will be used. Current " + "file %.", d, current_input_source->getPath()); } else { prior = d; } } catch (const std::exception& e) { - logger->warn( - "Weight '{0}' is not valid for the prototype '{1}'. Message: {2}. Default value will be " - "used. Current file {3}.", + COLORER_LOG_WARN( + "Weight '%' is not valid for the prototype '%'. Message: %. Default value will be " + "used. Current file %.", weight, current_parse_prototype->getName(), e.what(), current_input_source->getPath()); } } @@ -340,7 +340,7 @@ void HrcLibrary::Impl::addPrototypeParameters(const XMLNode& elem, FileType* cur const auto& name = node.getAttrValue(hrcParamAttrName); const auto& value = node.getAttrValue(hrcParamAttrValue); if (name.isEmpty() || value.isEmpty()) { - logger->warn("Bad parameter in prototype '{0}'", current_parse_prototype->getName()); + COLORER_LOG_WARN("Bad parameter in prototype '%'", current_parse_prototype->getName()); continue; } auto& tp = current_parse_prototype->pimpl->addParam(name, value); @@ -350,7 +350,7 @@ void HrcLibrary::Impl::addPrototypeParameters(const XMLNode& elem, FileType* cur } } else { - logger->warn("Unused element '{0}' in prototype '{1}'. Current file {2}.", node.name, + COLORER_LOG_WARN("Unused element '%' in prototype '%'. Current file %.", node.name, current_parse_prototype->pimpl->name, current_input_source->getPath()); } } @@ -361,18 +361,18 @@ void HrcLibrary::Impl::addType(const XMLNode& elem) const auto& typeName = elem.getAttrValue(hrcTypeAttrName); if (typeName.isEmpty()) { - logger->error("Unnamed type found"); + COLORER_LOG_ERROR("Unnamed type found"); return; } const auto type_ref = fileTypeHash.find(typeName); if (type_ref == fileTypeHash.end()) { - logger->error("Type '%s' without prototype", typeName); + COLORER_LOG_ERROR("Type '%s' without prototype", typeName); return; } auto *const type = type_ref->second; if (type->pimpl->type_loading) { - logger->warn("Type '{0}' is loading already. Current file {1}", typeName, current_input_source->getPath()); + COLORER_LOG_WARN("Type '%' is loading already. Current file %", typeName, current_input_source->getPath()); return; } @@ -389,7 +389,7 @@ void HrcLibrary::Impl::addType(const XMLNode& elem) type->pimpl->baseScheme = sh == schemeHash.end() ? nullptr : sh->second; } if (type->pimpl->baseScheme == nullptr && !type->pimpl->isPackage) { - logger->warn("Type '{0}' has no default scheme", typeName); + COLORER_LOG_WARN("Type '%' has no default scheme", typeName); } type->pimpl->loadDone = true; current_parse_type = o_parseType; @@ -421,7 +421,7 @@ void HrcLibrary::Impl::addTypeRegion(const XMLNode& elem) const auto& regionName = elem.getAttrValue(hrcRegionAttrName); if (regionName.isEmpty()) { - logger->error("No 'name' attribute in element"); + COLORER_LOG_ERROR("No 'name' attribute in element"); return; } const auto qname1 = qualifyOwnName(UnicodeString(regionName)); @@ -429,7 +429,7 @@ void HrcLibrary::Impl::addTypeRegion(const XMLNode& elem) return; } if (regionNamesHash.find(*qname1) != regionNamesHash.end()) { - logger->warn("Duplicate region '{0}' definition in type '{1}'", *qname1, current_parse_type->getName()); + COLORER_LOG_WARN("Duplicate region '%' definition in type '%'", *qname1, current_parse_type->getName()); return; } @@ -446,7 +446,7 @@ void HrcLibrary::Impl::addTypeEntity(const XMLNode& elem) { const auto& entityName = elem.getAttrValue(hrcEntityAttrName); if (entityName.isEmpty() || !elem.isExist(hrcEntityAttrValue)) { - logger->error("Bad entity attributes"); + COLORER_LOG_ERROR("Bad entity attributes"); return; } const auto& entityValue = elem.getAttrValue(hrcEntityAttrValue); @@ -462,7 +462,7 @@ void HrcLibrary::Impl::addTypeImport(const XMLNode& elem) { const auto& typeParam = elem.getAttrValue(hrcImportAttrType); if (typeParam.isEmpty() || fileTypeHash.find(typeParam) == fileTypeHash.end()) { - logger->error("Import with bad '{0}' attribute in type '{1}'", typeParam, current_parse_type->pimpl->name); + COLORER_LOG_ERROR("Import with bad '%' attribute in type '%'", typeParam, current_parse_type->pimpl->name); return; } current_parse_type->pimpl->importVector.emplace_back(typeParam); @@ -474,12 +474,12 @@ void HrcLibrary::Impl::addScheme(const XMLNode& elem) // todo check schemeName const auto qSchemeName = qualifyOwnName(schemeName); if (qSchemeName == nullptr) { - logger->error("bad scheme name in type '{0}'", current_parse_type->pimpl->name); + COLORER_LOG_ERROR("bad scheme name in type '%'", current_parse_type->pimpl->name); return; } if (schemeHash.find(*qSchemeName) != schemeHash.end() || disabledSchemes.find(*qSchemeName) != disabledSchemes.end()) { - logger->error("duplicate scheme name '{0}'", *qSchemeName); + COLORER_LOG_ERROR("duplicate scheme name '%'", *qSchemeName); return; } @@ -530,7 +530,7 @@ void HrcLibrary::Impl::addSchemeInherit(SchemeImpl* scheme, const XMLNode& elem) { auto nqSchemeName = elem.getAttrValue(hrcInheritAttrScheme); if (nqSchemeName.isEmpty()) { - logger->error("there is empty scheme name in inherit block of scheme '{0}', skip this inherit block.", + COLORER_LOG_ERROR("there is empty scheme name in inherit block of scheme '%', skip this inherit block.", *scheme->schemeName); return; } @@ -547,7 +547,7 @@ void HrcLibrary::Impl::addSchemeInherit(SchemeImpl* scheme, const XMLNode& elem) const auto& x_schemeName = node.getAttrValue(hrcVirtualAttrScheme); const auto& x_substName = node.getAttrValue(hrcVirtualAttrSubstScheme); if (x_schemeName.isEmpty() || x_substName.isEmpty()) { - logger->error("there is bad virtualize attributes of scheme '{0}', skip this virtual block.", + COLORER_LOG_ERROR("there is bad virtualize attributes of scheme '%', skip this virtual block.", *scheme_node->schemeName); continue; } @@ -566,7 +566,7 @@ void HrcLibrary::Impl::addSchemeRegexp(SchemeImpl* scheme, const XMLNode& elem) } if (matchParam.isEmpty()) { - logger->error("there is no 'match' attribute in regexp of scheme '{0}', skip this regexp block.", + COLORER_LOG_ERROR("there is no 'match' attribute in regexp of scheme '%', skip this regexp block.", *scheme->schemeName); return; } @@ -574,7 +574,7 @@ void HrcLibrary::Impl::addSchemeRegexp(SchemeImpl* scheme, const XMLNode& elem) const auto entMatchParam = useEntities(&matchParam); auto regexp = std::make_unique(entMatchParam.get()); if (!regexp->isOk()) { - logger->error("fault compiling regexp '{0}' of scheme '{1}', skip this regexp block.", *entMatchParam, + COLORER_LOG_ERROR("fault compiling regexp '%' of scheme '%', skip this regexp block.", *entMatchParam, *scheme->schemeName); return; } @@ -625,16 +625,16 @@ void HrcLibrary::Impl::addSchemeBlock(SchemeImpl* scheme, const XMLNode& elem) } if (start_param.isEmpty()) { - logger->error("there is no 'start' attribute in block of scheme '{0}', skip this block.", *scheme->schemeName); + COLORER_LOG_ERROR("there is no 'start' attribute in block of scheme '%', skip this block.", *scheme->schemeName); return; } if (end_param.isEmpty()) { - logger->error("there is no 'end' attribute in block of scheme '{0}', skip this block.", *scheme->schemeName); + COLORER_LOG_ERROR("there is no 'end' attribute in block of scheme '%', skip this block.", *scheme->schemeName); return; } const auto& schemeName = elem.getAttrValue(hrcBlockAttrScheme); if (schemeName.isEmpty()) { - logger->error("there is no 'scheme' attribute in block of scheme '{0}', skip this block.", *scheme->schemeName); + COLORER_LOG_ERROR("there is no 'scheme' attribute in block of scheme '%', skip this block.", *scheme->schemeName); return; } @@ -642,7 +642,7 @@ void HrcLibrary::Impl::addSchemeBlock(SchemeImpl* scheme, const XMLNode& elem) auto start_regexp = std::make_unique(startParam.get()); start_regexp->setPositionMoves(false); if (!start_regexp->isOk()) { - logger->error("fault compiling start regexp '{0}' in block of scheme '{1}', skip this block.", *startParam, + COLORER_LOG_ERROR("fault compiling start regexp '%' in block of scheme '%', skip this block.", *startParam, *scheme->schemeName); return; } @@ -653,7 +653,7 @@ void HrcLibrary::Impl::addSchemeBlock(SchemeImpl* scheme, const XMLNode& elem) end_regexp->setBackRE(start_regexp.get()); end_regexp->setRE(endParam.get()); if (!end_regexp->isOk()) { - logger->error("fault compiling end regexp '{0}' in block of scheme '{1}', skip this block.", *startParam, + COLORER_LOG_ERROR("fault compiling end regexp '%' in block of scheme '%', skip this block.", *startParam, *scheme->schemeName); return; } @@ -681,8 +681,8 @@ void HrcLibrary::Impl::parseSchemeKeywords(SchemeImpl* scheme, const XMLNode& el auto rg_tmpl = UnicodeString(u"region"); const Region* region = getNCRegion(&elem, rg_tmpl); if (region == nullptr) { - logger->error( - "there is no 'region' attribute in keywords block of scheme '{0}', skip this keywords " + COLORER_LOG_ERROR( + "there is no 'region' attribute in keywords block of scheme '%', skip this keywords " "block.", *scheme->schemeName); return; @@ -694,8 +694,8 @@ void HrcLibrary::Impl::parseSchemeKeywords(SchemeImpl* scheme, const XMLNode& el const uUnicodeString entWordDiv = useEntities(&worddiv); us_worddiv = UStr::createCharClass(*entWordDiv.get(), 0, nullptr, false); if (us_worddiv == nullptr) { - logger->error( - "fault compiling worddiv regexp '{0}' in keywords block of scheme '{1}'. skip this " + COLORER_LOG_ERROR( + "fault compiling worddiv regexp '%' in keywords block of scheme '%'. skip this " "keywords block.", *entWordDiv, *scheme->schemeName); } @@ -735,7 +735,7 @@ void HrcLibrary::Impl::addSchemeKeyword(const XMLNode& elem, const SchemeImpl* s { const auto& keyword_value = elem.getAttrValue(hrcWordAttrName); if (keyword_value.isEmpty()) { - logger->warn("the 'name' attribute in the '{1}' element of scheme '{0}' is empty or missing, skip it.", + COLORER_LOG_WARN("the 'name' attribute in the '%' element of scheme '%' is empty or missing, skip it.", *scheme->schemeName, keyword_type == KeywordInfo::KeywordType::KT_WORD ? "word" : "symb"); return; } @@ -843,10 +843,10 @@ void HrcLibrary::Impl::loadBlockRegions(SchemeNodeBlock* node, const XMLNode& el void HrcLibrary::Impl::updateSchemeLink(uUnicodeString& scheme_name, SchemeImpl** scheme_impl, byte scheme_type, const SchemeImpl* current_scheme) { - static const char* message[4] = {"cannot resolve scheme name '{0}' of block in scheme '{1}'", - "cannot resolve scheme name '{0}' of inherit in scheme '{1}'", - "cannot resolve scheme name '{0}' of virtual in scheme '{1}'", - "cannot resolve subst-scheme name '{0}' of virtual in scheme '{1}'"}; + static const char* message[4] = {"cannot resolve scheme name '%' of block in scheme '%'", + "cannot resolve scheme name '%' of inherit in scheme '%'", + "cannot resolve scheme name '%' of virtual in scheme '%'", + "cannot resolve subst-scheme name '%' of virtual in scheme '%'"}; if (scheme_name != nullptr && *scheme_impl == nullptr) { const auto schemeName = qualifyForeignName(scheme_name.get(), QualifyNameType::QNT_SCHEME, true); @@ -854,7 +854,7 @@ void HrcLibrary::Impl::updateSchemeLink(uUnicodeString& scheme_name, SchemeImpl* *scheme_impl = schemeHash.find(*schemeName)->second; } else { - logger->error(message[scheme_type], *scheme_name, *current_scheme->schemeName); + COLORER_LOG_ERROR(message[scheme_type], *scheme_name, *current_scheme->schemeName); } scheme_name.reset(); @@ -876,16 +876,16 @@ void HrcLibrary::Impl::updateLinks() if (snode->type == SchemeNode::SchemeNodeType::SNT_BLOCK) { auto *snode_block = static_cast(snode.get()); - updateSchemeLink(snode_block->schemeName, &snode_block->scheme, 1, scheme); + updateSchemeLink(snode_block->schemeName, &snode_block->scheme, 0, scheme); } if (snode->type == SchemeNode::SchemeNodeType::SNT_INHERIT) { auto *snode_inherit = static_cast(snode.get()); - updateSchemeLink(snode_inherit->schemeName, &snode_inherit->scheme, 2, scheme); + updateSchemeLink(snode_inherit->schemeName, &snode_inherit->scheme, 1, scheme); for (auto *vt : snode_inherit->virtualEntryVector) { - updateSchemeLink(vt->virtSchemeName, &vt->virtScheme, 3, scheme); - updateSchemeLink(vt->substSchemeName, &vt->substScheme, 4, scheme); + updateSchemeLink(vt->virtSchemeName, &vt->virtScheme, 2, scheme); + updateSchemeLink(vt->substSchemeName, &vt->substScheme, 3, scheme); } } } @@ -902,7 +902,7 @@ uUnicodeString HrcLibrary::Impl::qualifyOwnName(const UnicodeString& name) auto colon = name.indexOf(':'); if (colon != -1) { if (UnicodeString(name, 0, colon).compare(current_parse_type->pimpl->name) != 0) { - logger->error("type name qualifer in '{0}' doesn't match current type '{1}'", name, + COLORER_LOG_ERROR("type name qualifer in '%' doesn't match current type '%'", name, current_parse_type->pimpl->name); return nullptr; } @@ -919,19 +919,19 @@ bool HrcLibrary::Impl::checkNameExist(const UnicodeString* name, FileType* parse { if (qntype == QualifyNameType::QNT_DEFINE && regionNamesHash.find(*name) == regionNamesHash.end()) { if (logErrors) { - logger->error("region '{0}', referenced in type '{1}', is not defined", *name, parseType->pimpl->name); + COLORER_LOG_ERROR("region '%', referenced in type '%', is not defined", *name, parseType->pimpl->name); } return false; } if (qntype == QualifyNameType::QNT_ENTITY && schemeEntitiesHash.find(*name) == schemeEntitiesHash.end()) { if (logErrors) { - logger->error("entity '{0}', referenced in type '{1}', is not defined", *name, parseType->pimpl->name); + COLORER_LOG_ERROR("entity '%', referenced in type '%', is not defined", *name, parseType->pimpl->name); } return false; } if (qntype == QualifyNameType::QNT_SCHEME && schemeHash.find(*name) == schemeHash.end()) { if (logErrors) { - logger->error("scheme '{0}', referenced in type '{1}', is not defined", *name, parseType->pimpl->name); + COLORER_LOG_ERROR("scheme '%', referenced in type '%', is not defined", *name, parseType->pimpl->name); } return false; } @@ -954,7 +954,7 @@ uUnicodeString HrcLibrary::Impl::qualifyForeignName(const UnicodeString* name, Q if (prefType == nullptr) { if (logErrors) { - logger->error("type name qualifer in '{0}' doesn't match any type", *name); + COLORER_LOG_ERROR("type name qualifer in '%' doesn't match any type", *name); } return nullptr; } @@ -985,7 +985,7 @@ uUnicodeString HrcLibrary::Impl::qualifyForeignName(const UnicodeString* name, Q } } if (logErrors) { - logger->error("unqualified name '{0}' doesn't belong to any imported type [{1}]", *name, + COLORER_LOG_ERROR("unqualified name '%' doesn't belong to any imported type [%]", *name, current_input_source->getPath()); } } diff --git a/colorer/src/Colorer-library/src/colorer/parsers/ParserFactoryImpl.cpp b/colorer/src/Colorer-library/src/colorer/parsers/ParserFactoryImpl.cpp index 435bc8a3f..3fc66dd5c 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/ParserFactoryImpl.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/ParserFactoryImpl.cpp @@ -18,7 +18,7 @@ ParserFactory::Impl::~Impl() void ParserFactory::Impl::loadCatalog(const UnicodeString* catalog_path) { if (!catalog_path || catalog_path->isEmpty()) { - logger->debug("loadCatalog for empty path"); + COLORER_LOG_DEBUG("loadCatalog for empty path"); auto env = colorer::Environment::getOSVariable("COLORER_CATALOG"); if (!env || env->isEmpty()) { @@ -27,23 +27,23 @@ void ParserFactory::Impl::loadCatalog(const UnicodeString* catalog_path) base_catalog_path = colorer::Environment::normalizePath(env.get()); } else { - logger->debug("loadCatalog for {0}", *catalog_path); + COLORER_LOG_DEBUG("loadCatalog for %", *catalog_path); base_catalog_path = colorer::Environment::normalizePath(catalog_path); } parseCatalog(*base_catalog_path); - logger->debug("start load hrc files"); + COLORER_LOG_DEBUG("start load hrc files"); for (const auto& location : hrc_locations) { loadHrcPath(location); } - logger->debug("end load hrc files"); + COLORER_LOG_DEBUG("end load hrc files"); } void ParserFactory::Impl::loadHrcPath(const UnicodeString& location) { try { - logger->debug("try load '{0}'", location); + COLORER_LOG_DEBUG("try load '%'", location); if (XmlInputSource::isFileURI(*base_catalog_path, &location)) { auto files = colorer::Environment::getFilesFromPath(base_catalog_path.get(), &location, ".hrc"); for (auto& file : files) { @@ -54,7 +54,7 @@ void ParserFactory::Impl::loadHrcPath(const UnicodeString& location) loadHrc(location, base_catalog_path.get()); } } catch (const Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); } } @@ -64,8 +64,8 @@ void ParserFactory::Impl::loadHrc(const UnicodeString& hrc_path, const UnicodeSt try { hrc_library->loadSource(&dfis); } catch (Exception& e) { - logger->error("Can't load hrc: {0}", dfis.getPath()); - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("Can't load hrc: %", dfis.getPath()); + COLORER_LOG_ERROR("%", e.what()); } } @@ -183,8 +183,8 @@ void ParserFactory::Impl::fillMapper(const UnicodeString& classID, const Unicode XmlInputSource dfis(idx, base_catalog_path.get()); mapper.loadRegionMappings(dfis); } catch (Exception& e) { - logger->error("Can't load hrd: "); - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("Can't load hrd: "); + COLORER_LOG_ERROR("%", e.what()); throw ParserFactoryException("Error load hrd"); } } diff --git a/colorer/src/Colorer-library/src/colorer/parsers/TextParserHelpers.cpp b/colorer/src/Colorer-library/src/colorer/parsers/TextParserHelpers.cpp index 94e9d9196..74d5f3cc2 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/TextParserHelpers.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/TextParserHelpers.cpp @@ -5,7 +5,7 @@ ParseCache::~ParseCache() { - //CTRACE(logger->trace("[TPCache] ~ParseCache():{0},{1}-{2}", *scheme->getName(), sline, eline)); + //COLORER_LOG_DEEPTRACE("[TPCache] ~ParseCache():%,%-%", *scheme->getName(), sline, eline); delete backLine; delete children; prev = nullptr; @@ -32,7 +32,7 @@ ParseCache* ParseCache::searchLine(int ln, ParseCache** cache) ParseCache *r1 = nullptr, *r2 = nullptr, *tmp = this; *cache = nullptr; while (tmp) { - CTRACE(logger->trace("[TPCache] searchLine() tmp:{0},{1}-{2}", *tmp->scheme->getName(), tmp->sline, tmp->eline)); + COLORER_LOG_DEEPTRACE("[TPCache] searchLine() tmp:%,%-%", *tmp->scheme->getName(), tmp->sline, tmp->eline); if (tmp->sline <= ln && tmp->eline >= ln) { if (tmp->children) { r1 = tmp->children->searchLine(ln, &r2); diff --git a/colorer/src/Colorer-library/src/colorer/parsers/TextParserImpl.cpp b/colorer/src/Colorer-library/src/colorer/parsers/TextParserImpl.cpp index dfd9bc72f..7f9335afb 100644 --- a/colorer/src/Colorer-library/src/colorer/parsers/TextParserImpl.cpp +++ b/colorer/src/Colorer-library/src/colorer/parsers/TextParserImpl.cpp @@ -2,7 +2,7 @@ TextParser::Impl::Impl() { - CTRACE(logger->trace("[TextParserImpl] constructor")); + COLORER_LOG_DEEPTRACE("[TextParserImpl] constructor"); initCache(); } @@ -42,7 +42,7 @@ int TextParser::Impl::parse(int from, int num, TextParseMode mode) breakParsing = false; updateCache = (mode == TextParseMode::TPM_CACHE_UPDATE); - CTRACE(logger->trace("[TextParserImpl] parse from={0}, num={1}", from, num)); + COLORER_LOG_DEEPTRACE("[TextParserImpl] parse from=%, num=%", from, num); /* Check for initial bad conditions */ if (!regionHandler || !lineSource || !baseScheme) { return from; @@ -61,11 +61,11 @@ int TextParser::Impl::parse(int from, int num, TextParseMode mode) if (mode == TextParseMode::TPM_CACHE_READ || mode == TextParseMode::TPM_CACHE_UPDATE) { parent = cache->searchLine(from, &forward); if (parent != nullptr) { - CTRACE(logger->trace("[TPCache] searchLine() parent:{0},{1}-{2}", *parent->scheme->getName(), - parent->sline, parent->eline)); + COLORER_LOG_DEEPTRACE("[TPCache] searchLine() parent:%,%-%", *parent->scheme->getName(), + parent->sline, parent->eline); } } - CTRACE(logger->trace("[TextParserImpl] parse: cache filled")); + COLORER_LOG_DEEPTRACE("[TextParserImpl] parse: cache filled"); do { if (!forward) { @@ -86,7 +86,7 @@ int TextParser::Impl::parse(int from, int num, TextParseMode mode) baseScheme = parent->scheme; stackLevel = 0; - CTRACE(logger->trace("[TextParserImpl] parse: goes into colorize()")); + COLORER_LOG_DEEPTRACE("[TextParserImpl] parse: goes into colorize()"); if (parent != cache) { vtlist->restore(parent->vcache); parent->clender->end->setBackTrace(parent->backLine, &parent->matchstart); @@ -245,8 +245,8 @@ int TextParser::Impl::searchKW(const SchemeNodeKeywords* node, int /*no*/, int l } } if (!badbound) { - CTRACE(logger->trace("[TextParserImpl] KW matched. gx={0}, region={1}", gx, - node->kwList->kwList[pos].region->getName())); + COLORER_LOG_DEEPTRACE("[TextParserImpl] KW matched. gx=%, region=%", gx, + node->kwList->kwList[pos].region->getName()); addRegion(current_parse_line, gx, gx + kwlen, node->kwList->kwList[pos].region); gx += kwlen; return MATCH_RE; @@ -307,7 +307,7 @@ int TextParser::Impl::searchRE(SchemeNodeRegexp* node, int /*no*/, int lowLen, i if (!node->start->parse(str, gx, node->lowPriority ? lowLen : hiLen, &match, schemeStart)) { return MATCH_NOTHING; } - CTRACE(logger->trace("[TextParserImpl] RE matched. gx={0}", gx)); + COLORER_LOG_DEEPTRACE("[TextParserImpl] RE matched. gx=%", gx); for (int i = 0; i < match.cMatch; i++) { addRegion(current_parse_line, match.s[i], match.e[i], node->regions[i]); } @@ -340,7 +340,7 @@ int TextParser::Impl::searchBL(SchemeNodeBlock* node, int no, int lowLen, int hi } // есть совпадение - CTRACE(logger->trace("[TextParserImpl] Scheme matched. gx={0}", gx)); + COLORER_LOG_DEEPTRACE("[TextParserImpl] Scheme matched. gx=%", gx); gx = match.e[0]; // проверяем наличие замены через virtual для данной схемы SchemeImpl* ssubst = vtlist->pushvirt(node->scheme); @@ -453,7 +453,7 @@ int TextParser::Impl::searchBL(SchemeNodeBlock* node, int no, int lowLen, int hi int TextParser::Impl::searchMatch(const SchemeImpl* cscheme, int no, int lowLen, int hiLen) { - CTRACE(logger->trace("[TextParserImpl] searchMatch: entered scheme \"{0}\"", *cscheme->getName())); + COLORER_LOG_DEEPTRACE("[TextParserImpl] searchMatch: entered scheme \"%\"", *cscheme->getName()); if (!cscheme) { return MATCH_NOTHING; @@ -462,9 +462,9 @@ int TextParser::Impl::searchMatch(const SchemeImpl* cscheme, int no, int lowLen, int idx = 0; #endif for (auto const& schemeNode : cscheme->nodes) { - CTRACE(logger->trace("[TextParserImpl] searchMatch: processing node:{0}/{1}, type:{2}", idx + 1, + COLORER_LOG_DEEPTRACE("[TextParserImpl] searchMatch: processing node:%/%, type:%", idx + 1, cscheme->nodes.size(), - SchemeNode::schemeNodeTypeNames[static_cast(schemeNode->type)])); + SchemeNode::schemeNodeTypeNames[static_cast(schemeNode->type)]); switch (schemeNode->type) { case SchemeNode::SchemeNodeType::SNT_INHERIT: { auto schemeNodeInherit = static_cast(schemeNode.get()); @@ -514,7 +514,7 @@ bool TextParser::Impl::colorize(CRegExp* root_end_re, bool lowContentPriority) stackLevel++; for (; current_parse_line < end_line4parse;) { - CTRACE(logger->trace("[TextParserImpl] colorize: line no {0}", current_parse_line)); + COLORER_LOG_DEEPTRACE("[TextParserImpl] colorize: line no %", current_parse_line); // clears line at start, // prevents multiple requests on each line if (clearLine != current_parse_line) { diff --git a/colorer/src/Colorer-library/src/colorer/strings/icu/Encodings.cpp b/colorer/src/Colorer-library/src/colorer/strings/icu/Encodings.cpp index aeedb8266..ae2ec7fb0 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/icu/Encodings.cpp +++ b/colorer/src/Colorer-library/src/colorer/strings/icu/Encodings.cpp @@ -12,7 +12,7 @@ uUnicodeString Encodings::toUnicodeString(char* data, int32_t len) int32_t signatureLength; encoding = ucnv_detectUnicodeSignature(data, len, &signatureLength, &status); if (U_FAILURE(status)) { - logger->error("Encodings: Error \"{0}\" from ucnv_detectUnicodeSignature()\n", + COLORER_LOG_ERROR("Encodings: Error \"%\" from ucnv_detectUnicodeSignature()\n", u_errorName(status)); throw Exception("Error from ucnv_detectUnicodeSignature"); } diff --git a/colorer/src/Colorer-library/src/colorer/strings/icu/UStr.cpp b/colorer/src/Colorer-library/src/colorer/strings/icu/UStr.cpp index 486883241..7522336e7 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/icu/UStr.cpp +++ b/colorer/src/Colorer-library/src/colorer/strings/icu/UStr.cpp @@ -225,7 +225,7 @@ bool UStr::HexToUInt(const UnicodeString& str_hex, unsigned int* result) *result = std::stoul(UStr::to_stdstr(&s), nullptr, 16); return true; } catch (std::exception& e) { - logger->error("Can`t convert {0} to int. {1}", str_hex, e.what()); + COLORER_LOG_ERROR("Can`t convert % to int. %", str_hex, e.what()); return false; } } diff --git a/colorer/src/Colorer-library/src/colorer/strings/icu/UnicodeLogger.h b/colorer/src/Colorer-library/src/colorer/strings/icu/UnicodeLogger.h deleted file mode 100644 index ea81b7a43..000000000 --- a/colorer/src/Colorer-library/src/colorer/strings/icu/UnicodeLogger.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef COLORER_UNICODELOGGER_H -#define COLORER_UNICODELOGGER_H - -#include "fmt/format.h" -#include "unicode/unistr.h" - -namespace fmt { -template <> -struct formatter -{ - template - constexpr auto parse(ParseContext& ctx) - { - return ctx.begin(); - } - - template - auto format(const icu::UnicodeString& p, FormatContext& ctx) - { - std::string result8; - p.toUTF8String(result8); - return format_to(ctx.out(), "{0}", result8); - } -}; - -template <> -struct formatter> -{ - template - constexpr auto parse(ParseContext& ctx) - { - return ctx.begin(); - } - - template - auto format(const std::unique_ptr& p, FormatContext& ctx) - { - std::string result8; - p->toUTF8String(result8); - return format_to(ctx.out(), "{0}", result8); - } -}; -} // namespace fmt - -#endif // COLORER_UNICODELOGGER_H diff --git a/colorer/src/Colorer-library/src/colorer/strings/icu/common_icu.h b/colorer/src/Colorer-library/src/colorer/strings/icu/common_icu.h index ae6d16c94..be9a5d5b0 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/icu/common_icu.h +++ b/colorer/src/Colorer-library/src/colorer/strings/icu/common_icu.h @@ -1,7 +1,7 @@ #ifndef COLORER_COMMON_ICU_H #define COLORER_COMMON_ICU_H -#include +#include "unicode/uniset.h" #include using UnicodeString = icu::UnicodeString; diff --git a/colorer/src/Colorer-library/src/colorer/strings/icu/strings.h b/colorer/src/Colorer-library/src/colorer/strings/icu/strings.h index 05f47318a..d653164e4 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/icu/strings.h +++ b/colorer/src/Colorer-library/src/colorer/strings/icu/strings.h @@ -7,8 +7,5 @@ #include "colorer/strings/icu/UStr.h" #include "colorer/strings/icu/UnicodeStringContainer.h" #include "colorer/strings/icu/UnicodeTools.h" -#ifndef COLORER_FEATURE_DUMMYLOGGER -#include "colorer/strings/icu/UnicodeLogger.h" -#endif #endif // COLORER_STRINGS_H diff --git a/colorer/src/Colorer-library/src/colorer/strings/legacy/UStr.cpp b/colorer/src/Colorer-library/src/colorer/strings/legacy/UStr.cpp index dfa6b8644..967411e1b 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/legacy/UStr.cpp +++ b/colorer/src/Colorer-library/src/colorer/strings/legacy/UStr.cpp @@ -75,7 +75,7 @@ bool UStr::HexToUInt(const UnicodeString& str_hex, unsigned int* result) *result = std::stoul(UStr::to_stdstr(&s), nullptr, 16); return true; } catch (std::exception& e) { - logger->error("Can`t convert {0} to int. {1}", str_hex, e.what()); + COLORER_LOG_ERROR("Can`t convert % to int. %", str_hex, e.what()); return false; } } diff --git a/colorer/src/Colorer-library/src/colorer/strings/legacy/UnicodeLogger.h b/colorer/src/Colorer-library/src/colorer/strings/legacy/UnicodeLogger.h deleted file mode 100644 index 2d9c35313..000000000 --- a/colorer/src/Colorer-library/src/colorer/strings/legacy/UnicodeLogger.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef COLORER_UNICODELOGGER_H -#define COLORER_UNICODELOGGER_H - -#include "fmt/format.h" -#include -#include "colorer/strings/legacy/UnicodeString.h" - -namespace fmt { -template <> -struct formatter -{ - template - constexpr auto parse(ParseContext& ctx) - { - return ctx.begin(); - } - - template - auto format(const UnicodeString& p, FormatContext& ctx) - { - std::string result8=p.getChars(); - return format_to(ctx.out(), "{0}", result8); - } -}; - -template <> -struct formatter> -{ - template - constexpr auto parse(ParseContext& ctx) - { - return ctx.begin(); - } - - template - auto format(const std::unique_ptr& p, FormatContext& ctx) - { - std::string result8=p->getChars(); - return format_to(ctx.out(), "{0}", result8); - } -}; -} // namespace fmt - -#endif // COLORER_UNICODELOGGER_H diff --git a/colorer/src/Colorer-library/src/colorer/strings/legacy/strings.h b/colorer/src/Colorer-library/src/colorer/strings/legacy/strings.h index 857709383..def6a746d 100644 --- a/colorer/src/Colorer-library/src/colorer/strings/legacy/strings.h +++ b/colorer/src/Colorer-library/src/colorer/strings/legacy/strings.h @@ -7,9 +7,5 @@ #include "colorer/strings/legacy/UStr.h" #include "colorer/strings/legacy/UnicodeStringContainer.h" #include "colorer/strings/legacy/UnicodeTools.h" -#ifndef COLORER_FEATURE_DUMMYLOGGER -#include "colorer/strings/legacy/UnicodeLogger.h" -#endif - #endif // COLORER_STRINGS_H diff --git a/colorer/src/Colorer-library/src/colorer/utils/Environment.cpp b/colorer/src/Colorer-library/src/colorer/utils/Environment.cpp index 72878289b..f1a68375d 100644 --- a/colorer/src/Colorer-library/src/colorer/utils/Environment.cpp +++ b/colorer/src/Colorer-library/src/colorer/utils/Environment.cpp @@ -19,33 +19,33 @@ fs::path Environment::to_filepath(const UnicodeString* str) uUnicodeString Environment::getOSVariable(const UnicodeString& name) { #ifdef WIN32 - logger->debug("get system environment '{0}'", name); + COLORER_LOG_DEBUG("get system environment '%'", name); auto str_name = UStr::to_stdwstr(&name); size_t sz = 0; auto result_error = _wgetenv_s(&sz, nullptr, 0, str_name.c_str()); if (result_error != 0 || sz == 0) { - logger->debug("'{0}' not set", name); + COLORER_LOG_DEBUG("'%' not set", name); return nullptr; } std::vector value(sz); result_error = _wgetenv_s(&sz, &value[0], sz, str_name.c_str()); if (result_error != 0) { - logger->debug("'{0}' not set", name); + COLORER_LOG_DEBUG("'%' not set", name); return nullptr; } auto result = std::make_unique(&value[0], int32_t(sz - 1)); - logger->debug("'{0}' = '{1}'", name, *result); + COLORER_LOG_DEBUG("'%' = '%'", name, *result); return result; #else - logger->debug("get system environment '{0}'", name); + COLORER_LOG_DEBUG("get system environment '%'", name); auto str_name = UStr::to_stdstr(&name); const char* const value = std::getenv(str_name.c_str()); if (!value) { - logger->debug("'{0}' not set", name); + COLORER_LOG_DEBUG("'%' not set", name); return nullptr; } else { - logger->debug("'{0}' = '{1}'", name, value); + COLORER_LOG_DEBUG("'%' = '%'", name, value); return std::make_unique(value); } #endif @@ -53,7 +53,7 @@ uUnicodeString Environment::getOSVariable(const UnicodeString& name) uUnicodeString Environment::expandEnvironment(const UnicodeString* path) { - logger->debug("expand system environment for '{0}'", *path); + COLORER_LOG_DEBUG("expand system environment for '%'", *path); #ifdef WIN32 std::wstring path_ws = UStr::to_stdwstr(path); size_t i = ExpandEnvironmentStringsW(path_ws.c_str(), nullptr, 0); @@ -72,7 +72,7 @@ uUnicodeString Environment::expandEnvironment(const UnicodeString* path) } result += text; - logger->debug("result of expand '{0}'", result); + COLORER_LOG_DEBUG("result of expand '%'", result); return std::make_unique(result.c_str()); #endif } diff --git a/colorer/src/Colorer-library/src/colorer/xml/libxml2/LibXmlReader.cpp b/colorer/src/Colorer-library/src/colorer/xml/libxml2/LibXmlReader.cpp index 85fc928ea..523e1d3d2 100644 --- a/colorer/src/Colorer-library/src/colorer/xml/libxml2/LibXmlReader.cpp +++ b/colorer/src/Colorer-library/src/colorer/xml/libxml2/LibXmlReader.cpp @@ -1,5 +1,6 @@ #include "colorer/xml/libxml2/LibXmlReader.h" #include +#include LibXmlReader::LibXmlReader(const UnicodeString& source_file) : xmldoc(nullptr) { @@ -125,7 +126,7 @@ void LibXmlReader::xml_error_func(void* /*ctx*/, const char* msg, ...) /* This shouldn't really happen */ if (rc < 0) { - logger->error("+++ out of cheese error. redo from start +++\n"); + COLORER_LOG_ERROR("+++ out of cheese error. redo from start +++\n"); slen = 0; memset(buf, 0, sizeof(buf)); return; @@ -141,7 +142,7 @@ void LibXmlReader::xml_error_func(void* /*ctx*/, const char* msg, ...) /* We're assuming here that the last character is \n. */ if (buf[slen - 1] == '\n') { buf[slen - 1] = '\0'; - logger->error("{0}", buf); + COLORER_LOG_ERROR("%", buf); memset(buf, 0, sizeof(buf)); slen = 0; } diff --git a/colorer/src/Colorer-library/src/colorer/xml/xercesc/BaseEntityResolver.cpp b/colorer/src/Colorer-library/src/colorer/xml/xercesc/BaseEntityResolver.cpp index 23a416252..f7def7bb6 100644 --- a/colorer/src/Colorer-library/src/colorer/xml/xercesc/BaseEntityResolver.cpp +++ b/colorer/src/Colorer-library/src/colorer/xml/xercesc/BaseEntityResolver.cpp @@ -10,7 +10,7 @@ xercesc::InputSource* BaseEntityResolver::resolveEntity(xercesc::XMLResourceIden XercesXmlInputSource::newInstance(resourceIdentifier->getSystemId(), resourceIdentifier->getBaseURI()); return input_source.release(); } catch (InputSourceException& e) { - logger->warn(e.what()); + COLORER_LOG_WARN(e.what()); // Если не можем открыть external entity, то отдаем пустой файл. // Тем самым гасим ошибку загрузки схемы. Работа продолжится, но раскраска будет не до конца верной. auto empty_buf = new xercesc::MemBufInputSource((const XMLByte*) "", 0, "dummy"); diff --git a/colorer/src/Colorer-library/src/colorer/xml/xercesc/XmlParserErrorHandler.cpp b/colorer/src/Colorer-library/src/colorer/xml/xercesc/XmlParserErrorHandler.cpp index dd94c2730..8fec67500 100644 --- a/colorer/src/Colorer-library/src/colorer/xml/xercesc/XmlParserErrorHandler.cpp +++ b/colorer/src/Colorer-library/src/colorer/xml/xercesc/XmlParserErrorHandler.cpp @@ -3,7 +3,7 @@ void XmlParserErrorHandler::warning(const xercesc::SAXParseException& toCatch) { - logger->warn("Warning at file {0}, line {1}, column {2}. Message: {3}", + COLORER_LOG_WARN("Warning at file %, line %, column %. Message: %", UStr::to_stdstr(toCatch.getSystemId()), toCatch.getLineNumber(), toCatch.getColumnNumber(), UStr::to_stdstr(toCatch.getMessage())); } @@ -11,7 +11,7 @@ void XmlParserErrorHandler::warning(const xercesc::SAXParseException& toCatch) void XmlParserErrorHandler::error(const xercesc::SAXParseException& toCatch) { fSawErrors = true; - logger->error("Error at file {0}, line {1}, column {2}. Message: {3}", + COLORER_LOG_ERROR("Error at file %, line %, column %. Message: %", UStr::to_stdstr(toCatch.getSystemId()), toCatch.getLineNumber(), toCatch.getColumnNumber(), UStr::to_stdstr(toCatch.getMessage())); } @@ -19,7 +19,7 @@ void XmlParserErrorHandler::error(const xercesc::SAXParseException& toCatch) void XmlParserErrorHandler::fatalError(const xercesc::SAXParseException& toCatch) { fSawErrors = true; - logger->error("Fatal error at file {0}, line {1}, column {2}. Message: {3}", + COLORER_LOG_ERROR("Fatal error at file %, line %, column %. Message: %", UStr::to_stdstr(toCatch.getSystemId()), toCatch.getLineNumber(), toCatch.getColumnNumber(), UStr::to_stdstr(toCatch.getMessage())); } diff --git a/colorer/src/pcolorer2/CerrLogger.h b/colorer/src/pcolorer2/CerrLogger.h new file mode 100644 index 000000000..615837d6d --- /dev/null +++ b/colorer/src/pcolorer2/CerrLogger.h @@ -0,0 +1,56 @@ +#ifndef SIMPLELOGGER_H +#define SIMPLELOGGER_H + +#include +#include +#include + +class CerrLogger : public Logger +{ + public: + static constexpr std::string_view LogLevelStr[] {"off", "error", "warning", + "info", "debug", "trace"}; + + CerrLogger() + { + const char* verbose_env = getenv("COLORER_VERBOSE"); + if (verbose_env) { + current_level = getLogLevel(verbose_env); + } + } + + ~CerrLogger() override = default; + + void log(Logger::LogLevel level, const char* /*filename_in*/, int /*line_in*/, + const char* /*funcname_in*/, const char* message) + { + if (level > current_level) { + return; + } + std::time_t const t = std::time(nullptr); + char mbstr[30]; + std::strftime(mbstr, sizeof(mbstr), "%FT%T", std::localtime(&t)); + std::cerr << "[" << mbstr << "] [FarColorer] [" << LogLevelStr[level] << "] "; + std::cerr << message << '\n'; + } + + Logger::LogLevel getLogLevel(const std::string& log_level) + { + int i = 0; + for (auto it : LogLevelStr) { + if (log_level == it) { + return static_cast(i); + } + i++; + } + if (log_level == "warn") { + current_level = Logger::LOG_WARN; + } + return Logger::LOG_OFF; + } + + private: + Logger::LogLevel current_level = Logger::LOG_OFF; +}; + +#endif // SIMPLELOGGER_H diff --git a/colorer/src/pcolorer2/FarEditor.cpp b/colorer/src/pcolorer2/FarEditor.cpp index a7f30c780..0764745a4 100644 --- a/colorer/src/pcolorer2/FarEditor.cpp +++ b/colorer/src/pcolorer2/FarEditor.cpp @@ -409,7 +409,7 @@ void FarEditor::locateFunction() } UnicodeString funcname(curLine, sword + 1, eword - sword - 1); - logger->debug("FC] Letter {0}", funcname); + COLORER_LOG_DEBUG("FC] Letter %", funcname); baseEditor->validate(-1, false); EditorSetPosition esp; OutlineItem* item_found = nullptr; diff --git a/colorer/src/pcolorer2/FarEditorSet.cpp b/colorer/src/pcolorer2/FarEditorSet.cpp index 9f6ce0525..e9d041c48 100644 --- a/colorer/src/pcolorer2/FarEditorSet.cpp +++ b/colorer/src/pcolorer2/FarEditorSet.cpp @@ -166,7 +166,7 @@ void FarEditorSet::openMenu() break; }; } catch (Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); UnicodeString msg("openMenu: "); msg.append(e.what()); showExceptionMessage(&msg); @@ -646,7 +646,7 @@ void FarEditorSet::configure(bool fromEditor) Info.DialogFree(hDlg); } catch (Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); UnicodeString msg("configure: "); msg.append(UnicodeString(e.what())); @@ -753,7 +753,7 @@ int FarEditorSet::editorEvent(int Event, void* Param) } } } catch (Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); UnicodeString msg("editorEvent: "); msg.append(UnicodeString(e.what())); @@ -803,7 +803,7 @@ bool FarEditorSet::TestLoadBase(const wchar_t* catalogPath, const wchar_t* userH try { regionMapperLocal = parserFactoryLocal->createStyledMapper(&DConsole, sTempHrdName); } catch (ParserFactoryException& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); regionMapperLocal = parserFactoryLocal->createStyledMapper(&DConsole, nullptr); } regionMapperLocal = nullptr; @@ -813,7 +813,7 @@ bool FarEditorSet::TestLoadBase(const wchar_t* catalogPath, const wchar_t* userH try { regionMapperLocal = parserFactoryLocal->createStyledMapper(&DRgb, sTempHrdNameTm); } catch (ParserFactoryException& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); regionMapperLocal = parserFactoryLocal->createStyledMapper(&DRgb, nullptr); } } @@ -840,7 +840,7 @@ bool FarEditorSet::TestLoadBase(const wchar_t* catalogPath, const wchar_t* userH } } } catch (Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); auto error_mes = UnicodeString(e.what()); showExceptionMessage(&error_mes); Info.RestoreScreen(scr); @@ -888,13 +888,13 @@ void FarEditorSet::ReloadBase() try { regionMapper = parserFactory->createStyledMapper(&hrdClass, &hrdName); } catch (ParserFactoryException& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); regionMapper = parserFactory->createStyledMapper(&hrdClass, nullptr); }; // устанавливаем фон редактора при каждой перезагрузке схем. SetBgEditor(); } catch (Exception& e) { - logger->error("{0}", e.what()); + COLORER_LOG_ERROR("%", e.what()); auto error_mes = UnicodeString(e.what()); showExceptionMessage(&error_mes); disableColorer(); diff --git a/colorer/src/pcolorer2/pcolorer.cpp b/colorer/src/pcolorer2/pcolorer.cpp index 9b0a4dd90..dd886a446 100644 --- a/colorer/src/pcolorer2/pcolorer.cpp +++ b/colorer/src/pcolorer2/pcolorer.cpp @@ -1,16 +1,7 @@ #include "pcolorer.h" #include #include "FarEditorSet.h" -#include "tools.h" - -#ifdef USESPDLOG -#include -#include - -std::shared_ptr logger; -#else -std::shared_ptr logger; -#endif +#include "CerrLogger.h" FarEditorSet* editorSet = nullptr; bool inEventProcess = false; @@ -18,17 +9,17 @@ PluginStartupInfo Info; FarStandardFunctions FSF; UnicodeString* PluginPath = nullptr; +std::unique_ptr logger; + SHAREDSYMBOL void PluginModuleOpen(const char* path) { UnicodeString module(path); int pos = module.lastIndexOf('/'); pos = module.lastIndexOf('/', pos); PluginPath = new UnicodeString(UnicodeString(module, 0, pos)); -#ifdef USESPDLOG - logger = spdlog::stderr_logger_mt("far2l-colorer"); -#else - logger = std::make_shared(); -#endif + + logger = std::make_unique(); + Log::registerLogger(*logger); } UnicodeString* GetConfigPath(const UnicodeString& sub) From a98df51eaf20e3994fdf75c31c5d3ce2c4c8ede2 Mon Sep 17 00:00:00 2001 From: Aleksey Dobrunov Date: Thu, 12 Sep 2024 21:15:15 +0500 Subject: [PATCH 20/27] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bd5e9675c..113ff0b17 100644 --- a/README.md +++ b/README.md @@ -218,7 +218,7 @@ cd far2l ``` * Install needed dependencies with MacPorts: ``` sh -sudo port install cmake pkgconfig wxWidgets-3.2 libssh openssl libxml2 libfmt uchardet neon +sudo port install cmake pkgconfig wxWidgets-3.2 libssh openssl libxml2 uchardet neon export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig ``` * OR if you prefer to use brew packages, then: From 7e9dbd1633a68c20b53fbbba91312351e11a5e8e Mon Sep 17 00:00:00 2001 From: Aleksey Dobrunov Date: Thu, 12 Sep 2024 21:43:52 +0500 Subject: [PATCH 21/27] fix warn from clang --- colorer/src/pcolorer2/CerrLogger.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorer/src/pcolorer2/CerrLogger.h b/colorer/src/pcolorer2/CerrLogger.h index 615837d6d..7ab9f96d3 100644 --- a/colorer/src/pcolorer2/CerrLogger.h +++ b/colorer/src/pcolorer2/CerrLogger.h @@ -22,7 +22,7 @@ class CerrLogger : public Logger ~CerrLogger() override = default; void log(Logger::LogLevel level, const char* /*filename_in*/, int /*line_in*/, - const char* /*funcname_in*/, const char* message) + const char* /*funcname_in*/, const char* message) override { if (level > current_level) { return; From 527364fec293b4238c9d62c7cdaaab27042e9d2c Mon Sep 17 00:00:00 2001 From: anta999 Date: Fri, 13 Sep 2024 22:15:35 +0400 Subject: [PATCH 22/27] update --- far2l/src/filefilterparams.cpp | 9 ++-- far2l/src/hilight.cpp | 79 ++++++++++++++++------------------ far2l/src/hilight.hpp | 11 +++-- far2l/src/panels/filelist.cpp | 2 +- far2l/src/panels/filelist.hpp | 2 +- far2l/src/panels/flshow.cpp | 7 ++- far2l/src/panels/flupdate.cpp | 10 ++--- 7 files changed, 58 insertions(+), 62 deletions(-) diff --git a/far2l/src/filefilterparams.cpp b/far2l/src/filefilterparams.cpp index 9c5ad38e6..cfec835e8 100644 --- a/far2l/src/filefilterparams.cpp +++ b/far2l/src/filefilterparams.cpp @@ -773,7 +773,7 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P int nLength = (int)SendDlgMessage(hDlg, DM_GETTEXTLENGTH, ID_HER_MARKEDIT, 0); if (nLength > HIGHLIGHT_MAX_MARK_LENGTH ) { - SendDlgMessage(hDlg, DM_SETTEXTPTR, ID_HER_MARKEDIT, (LONG_PTR)&fphlstate->hl.Mark[0]); + SendDlgMessage(hDlg, DM_SETTEXTPTRSILENT, ID_HER_MARKEDIT, (LONG_PTR)&fphlstate->hl.Mark[0]); } else { SendDlgMessage(hDlg, DM_GETTEXTPTR, ID_HER_MARKEDIT, (LONG_PTR)&fphlstate->hl.Mark[0]); @@ -798,9 +798,7 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P fphlstate->hl.MarkLen = nLength; } -// HighlightDlgUpdateUserControl(fphlstate); SendDlgMessage(hDlg, DM_REDRAW, 0, 0); - return TRUE; } @@ -1005,7 +1003,7 @@ bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) FilterDlg[ID_HER_COLOREXAMPLE].VBuf = fphlstate.vbuff; FilterDlg[ID_HER_MARKEDIT].strData = fphlstate.hl.Mark; - FilterDlg[ID_HER_MARKINHERIT].Selected = (fphlstate.hl.bMarkInherit ? 1 : 0); + FilterDlg[ID_HER_MARKINHERIT].Selected = ((fphlstate.hl.Flags & HL_FLAGS_MARK_INHERIT) ? 1 : 0); FilterDlg[ID_HER_CONTINUEPROCESSING].Selected = (FF->GetContinueProcessing() ? 1 : 0); FilterDlg[ID_FF_NAMEEDIT].strData = FF->GetTitle(); @@ -1189,7 +1187,8 @@ bool FileFilterConfig(FileFilterParams *FF, bool ColorConfig) if (FilterDlg[ID_FF_MATCHMASK].Selected && !FileMask.Set(FilterDlg[ID_FF_MASKEDIT].strData, 0)) continue; - fphlstate.hl.bMarkInherit = FilterDlg[ID_HER_MARKINHERIT].Selected; +// fphlstate.hl.Flags = 0; + fphlstate.hl.Flags = FilterDlg[ID_HER_MARKINHERIT].Selected; // HL_FLAGS_MARK_INHERIT FF->SetColors(&fphlstate.hl); FF->SetContinueProcessing(FilterDlg[ID_HER_CONTINUEPROCESSING].Selected != 0); diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index b7a71e858..1bd4465f3 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -245,7 +245,7 @@ static void LoadFilter(FileFilterParams *HData, ConfigReader &cfg_reader, const DWORD dwMarkLen = strMark.GetLength(); DWORD dwMarkChar = cfg_reader.GetUInt(HLS.MarkChar, 0); - hl.bMarkInherit = (dwMarkChar & 0xFF0000); + hl.Flags = (dwMarkChar & 0xFF0000) >> 23; dwMarkChar &= 0x0000FFFF; if (dwMarkLen) { @@ -364,16 +364,27 @@ static const DWORD FarColor[] = {COL_PANELTEXT, COL_PANELSELECTEDTEXT, COL_PANEL static const HighlightDataColor DefaultStartingColors = { - { {0x0, 0x0, 0x0, 0x0}, // Color[0][4] 0 = Black on black = default theme color + { {0x0, 0x0, 0x0, 0x0}, // Color[0][4] 0 = Black on black = default theme color {0x0, 0x0, 0x0, 0x0}}, // Color[1][4] - { {0x0, 0x0, 0x0, 0x0}, // Mask[0][4] // Transparency Masks 0 = fully transparent + { {0x0, 0x0, 0x0, 0x0}, // Mask[0][4] // Transparency Masks 0 = fully transparent {0x0, 0x0, 0x0, 0x0}}, // Mask[1][4] + 0, // size_t MarkLen; + 1, // flags; { 0 }, // wchar_t Mark + }; + +const HighlightDataColor ZeroColors = + { + { {0x0, 0x0, 0x0, 0x0}, // Color[0][4] 0 = Black on black = default theme color + {0x0, 0x0, 0x0, 0x0}}, // Color[1][4] + { {0x0, 0x0, 0x0, 0x0}, // Mask[0][4] // Transparency Masks 0 = fully transparent + {0x0, 0x0, 0x0, 0x0}}, // Mask[1][4] 0, // size_t MarkLen; - true // bool bMarkInherit; + 0, // flags; + { 0 }, // wchar_t Mark }; -const HighlightDataColor ZeroColors{{{0}}}; +//const HighlightDataColor ZeroColors{{{0}}}; static void ApplyBlackOnBlackColors(HighlightDataColor *hl) { @@ -406,7 +417,7 @@ static void ApplyStartColors(HighlightDataColor *hl) hl->Mask[HIGHLIGHTCOLORTYPE_MARKSTR][i] = hl->Mask[HIGHLIGHTCOLORTYPE_FILE][i]; } - hl->bMarkInherit = false; + hl->Flags = 0; hl->MarkLen = 0; hl->Mark[0] = 0; } @@ -433,7 +444,7 @@ static void ApplyColors(HighlightDataColor *hlDst, HighlightDataColor *hlSrc) // Унаследуем пометку из Src в Dst если она есть if (hlSrc->MarkLen) { // Если нет наследования в Src, то просто заменим метку на новую в Dst - if (!hlSrc->bMarkInherit) { + if (!(hlSrc->Flags & HL_FLAGS_MARK_INHERIT)) { hlDst->MarkLen = hlSrc->MarkLen; memcpy(hlDst->Mark, hlSrc->Mark, sizeof(wchar_t) * hlSrc->MarkLen); } @@ -446,7 +457,7 @@ static void ApplyColors(HighlightDataColor *hlDst, HighlightDataColor *hlSrc) } } } - else if (!hlSrc->bMarkInherit) { // Если нет наследования и метка пустая, то убираем метку совсем + else if (!(hlSrc->Flags & HL_FLAGS_MARK_INHERIT)) { // Если нет наследования и метка пустая, то убираем метку совсем hlDst->MarkLen = 0; } } @@ -470,7 +481,7 @@ class HighlightFilesChunk : protected Threaded uint64_t _CurrentTime; const TPointerArray &_HiData; FileListItem **_FileItem; - size_t _FileCount, _LongestMarkLength; + size_t _FileCount, _MarkLM; bool _UseAttrHighlighting; virtual void *ThreadProc() @@ -486,7 +497,7 @@ class HighlightFilesChunk : protected Threaded _HiData(HiData), _FileItem(FileItem), _FileCount(FileCount), - _LongestMarkLength(0), + _MarkLM(0), _UseAttrHighlighting(UseAttrHighlighting) {} @@ -517,13 +528,13 @@ class HighlightFilesChunk : protected Threaded } } - if (Colors.MarkLen > _LongestMarkLength) - _LongestMarkLength = Colors.MarkLen; + if (Colors.MarkLen > _MarkLM && Colors.MarkLen <= Opt.MaxFilenameIndentation) + _MarkLM = Colors.MarkLen; fli.ColorsPtr = PooledHighlightDataColor(Colors); } - return (void *)_LongestMarkLength; + return (void *)_MarkLM; } void *GetResult() { return GetThreadResult(); } @@ -534,12 +545,12 @@ class HighlightFilesChunk : protected Threaded } }; -void HighlightFiles::GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *_LongestMarkLength) +void HighlightFiles::GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *_MarkLM) { if (!FileItem || !FileCount) return; - size_t LongestMarkLength = 0; + size_t MarkLM = 0; size_t BestThreadsNum = std::max(BestThreadsCount(), 1u); std::list async_hfc; @@ -559,19 +570,17 @@ void HighlightFiles::GetHiColor(FileListItem **FileItem, size_t FileCount, bool } } - size_t len = (size_t)HighlightFilesChunk(CurrentTime, HiData, FileItem, FileCount, UseAttrHighlighting).DoNow(); - if (len > LongestMarkLength) - LongestMarkLength = len; + MarkLM = (size_t)HighlightFilesChunk(CurrentTime, HiData, FileItem, FileCount, UseAttrHighlighting).DoNow(); while(!async_hfc.empty( )) { - len = (size_t)async_hfc.back().GetResult(); - if (len > LongestMarkLength) - LongestMarkLength = len; + size_t len = (size_t)async_hfc.back().GetResult(); + if (len > MarkLM) + MarkLM = len; async_hfc.pop_back(); } - if (_LongestMarkLength && *_LongestMarkLength < LongestMarkLength ) - *_LongestMarkLength = LongestMarkLength; + if (_MarkLM && *_MarkLM < MarkLM ) + *_MarkLM = MarkLM; } int HighlightFiles::GetGroup(const FileListItem *fli) @@ -985,7 +994,7 @@ static void SaveFilter(FileFilterParams *CurHiData, ConfigWriter &cfg_writer, bo { // Save Mark str FARString strMark = L""; DWORD dwMarkChar = (hl.MarkLen == 1) ? hl.Mark[0] : 0; - dwMarkChar |= (0xFF0000 * hl.bMarkInherit); + dwMarkChar |= (0xFF0000 * (hl.Flags & HL_FLAGS_MARK_INHERIT)); cfg_writer.SetUInt(HLS.MarkChar, dwMarkChar); @@ -1050,25 +1059,7 @@ void HighlightFiles::SaveHiData() static bool operator==(const HighlightDataColor &hl1, const HighlightDataColor &hl2) { - if (hl1.MarkLen != hl2.MarkLen) - return false; - if (hl1.bMarkInherit != hl2.bMarkInherit) - return false; - - if (hl1.MarkLen) - if (memcmp(&hl1.Mark[0], &hl2.Mark[0], sizeof(wchar_t) * hl1.MarkLen)) - return false; - - for (size_t i = 0; i < ARRAYSIZE(hl1.Color); ++i) { - for (size_t j = 0; j < ARRAYSIZE(hl1.Color[i]); ++j) { - if (hl1.Color[i][j] != hl2.Color[i][j]) - return false; - if (hl1.Mask[i][j] != hl2.Mask[i][j]) - return false; - } - } - - return true; + return !memcmp(&hl1, &hl2, sizeof(HighlightDataColor)); } struct HighlightDataColorHash @@ -1076,6 +1067,7 @@ struct HighlightDataColorHash size_t operator()(const HighlightDataColor &hl) const { size_t out = hl.MarkLen * 0xFFFF; + for (size_t i = 0; i < ARRAYSIZE(hl.Color); ++i) { for (size_t j = 0; j < ARRAYSIZE(hl.Color[i]); ++j) { out ^= hl.Color[i][j] + hl.Mask[i][j] + ((i ^ j) << 16); @@ -1092,6 +1084,7 @@ static std::atomic s_last_color{&DefaultStartingColo const HighlightDataColor *PooledHighlightDataColor(const HighlightDataColor &color) { const HighlightDataColor *last_color = s_last_color.load(std::memory_order_relaxed); + if (color == *last_color) { return last_color; } diff --git a/far2l/src/hilight.hpp b/far2l/src/hilight.hpp index 2990e8e14..47781b824 100644 --- a/far2l/src/hilight.hpp +++ b/far2l/src/hilight.hpp @@ -53,14 +53,19 @@ enum enumHighlightDataColor HIGHLIGHTCOLORTYPE_MARKSTR = 1, }; +enum HIGHLIGHT_FLAGS +{ + HL_FLAGS_MARK_INHERIT = 1, +}; + struct HighlightDataColor { uint64_t Color[2][4]; // [0=file, 1=mark][0=normal,1=selected,2=undercursor,3=selectedundercursor]; // nonzero upper 3 bytes meaning foreground RGB, nonzero lower 3 bytes meaning background RGB uint64_t Mask[2][4]; // transparency mask, 0 = fully transparent - wchar_t Mark[HIGHLIGHT_MAX_MARK_LENGTH + 1]; // + null terminator + uint32_t Flags; uint32_t MarkLen; - bool bMarkInherit; + wchar_t Mark[HIGHLIGHT_MAX_MARK_LENGTH + 1]; // + null terminator }; class HighlightFiles @@ -84,7 +89,7 @@ class HighlightFiles public: void UpdateCurrentTime(); - void GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *LongestMarkLength); + void GetHiColor(FileListItem **FileItem, size_t FileCount, bool UseAttrHighlighting, size_t *MarkLM); int GetGroup(const FileListItem *fli); void HiEdit(int MenuPos); diff --git a/far2l/src/panels/filelist.cpp b/far2l/src/panels/filelist.cpp index 2c85a507a..d634337c1 100644 --- a/far2l/src/panels/filelist.cpp +++ b/far2l/src/panels/filelist.cpp @@ -123,7 +123,7 @@ FileList::FileList() SelFileSize(0), TotalFileSize(0), FreeDiskSize(0), - LongestMarkLength(0), + MarkLM(0), LastUpdateTime(0), Height(0), LeftPos(0), diff --git a/far2l/src/panels/filelist.hpp b/far2l/src/panels/filelist.hpp index 604b11ae2..2ce5a8244 100644 --- a/far2l/src/panels/filelist.hpp +++ b/far2l/src/panels/filelist.hpp @@ -194,7 +194,7 @@ class FileList : public Panel uint64_t SelFileSize; uint64_t TotalFileSize; uint64_t FreeDiskSize; - size_t LongestMarkLength; + size_t MarkLM; clock_t LastUpdateTime; int Height, Columns; std::deque _symlinks_backlog; diff --git a/far2l/src/panels/flshow.cpp b/far2l/src/panels/flshow.cpp index 6e2226aaa..e8f4ba6c8 100644 --- a/far2l/src/panels/flshow.cpp +++ b/far2l/src/panels/flshow.cpp @@ -953,8 +953,8 @@ void FileList::ShowList(int ShowStatus, int StartColumn) if (Opt.ShowFilenameMarks && Opt.Highlight ) { const HighlightDataColor *const hl = ListData[ListPos]->ColorsPtr; - if (Opt.FilenameMarksAllign && LongestMarkLength > padlen) - padlen = std::min(LongestMarkLength, (size_t)Opt.MaxFilenameIndentation); + if (Opt.FilenameMarksAllign && MarkLM > padlen) + padlen = std::min(MarkLM, (size_t)Opt.MaxFilenameIndentation); if (hl->MarkLen && Width > 2) { const uint64_t OldColor = GetColor(); @@ -1090,8 +1090,7 @@ void FileList::ShowList(int ShowStatus, int StartColumn) Text(FormatStr_Size(ListData[ListPos]->FileSize, ListData[ListPos]->PhysicalSize, ListData[ListPos]->strName, ListData[ListPos]->FileAttr, ListData[ListPos]->ShowFolderSize, ColumnType, ColumnTypes[K], - ColumnWidth) - .CPtr()); + ColumnWidth).CPtr()); break; } diff --git a/far2l/src/panels/flupdate.cpp b/far2l/src/panels/flupdate.cpp index ec86a2401..fe239e653 100644 --- a/far2l/src/panels/flupdate.cpp +++ b/far2l/src/panels/flupdate.cpp @@ -169,7 +169,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa TotalFileSize = 0; CacheSelIndex = -1; CacheSelClearIndex = -1; - LongestMarkLength = 0; + MarkLM = 0; if (Opt.ShowPanelFree) { uint64_t TotalSize, TotalFree; @@ -388,7 +388,7 @@ void FileList::ReadFileNames(int KeepSelection, int IgnoreVisible, int DrawMessa } if (Opt.Highlight && !ListData.IsEmpty()) - CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count(), false, &LongestMarkLength); + CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count(), false, &MarkLM); CreateChangeNotification(FALSE); CorrectPosition(); @@ -574,7 +574,7 @@ void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible) TotalFileSize = 0; CacheSelIndex = -1; CacheSelClearIndex = -1; - LongestMarkLength = 0; + MarkLM = 0; strPluginDizName.Clear(); @@ -648,13 +648,13 @@ void FileList::UpdatePlugin(int KeepSelection, int IgnoreVisible) } if (!ListData.IsEmpty() && ((Info.Flags & OPIF_USEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING))) CtrlObject->HiFiles->GetHiColor(&ListData[0], ListData.Count(), - (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &LongestMarkLength); + (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &MarkLM); if ((Info.Flags & OPIF_ADDDOTS) && !DotsPresent) { FileListItem *CurPtr = ListData.AddParentPoint(); if (CurPtr) { if ((Info.Flags & OPIF_USEHIGHLIGHTING) || (Info.Flags & OPIF_USEATTRHIGHLIGHTING)) - CtrlObject->HiFiles->GetHiColor(&CurPtr, 1, (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &LongestMarkLength ); + CtrlObject->HiFiles->GetHiColor(&CurPtr, 1, (Info.Flags & OPIF_USEATTRHIGHLIGHTING) != 0, &MarkLM ); if (Info.HostFile && *Info.HostFile) { FAR_FIND_DATA_EX FindData; From 857c85a6eeb46c478ca81d1f0f57db07523c2178 Mon Sep 17 00:00:00 2001 From: anta999 Date: Sun, 15 Sep 2024 14:43:56 +0400 Subject: [PATCH 23/27] removed last extra empty item in user menu --- far2l/src/filefilterparams.cpp | 22 ++++++++++++++++++---- far2l/src/hilight.cpp | 16 ++++++++++------ far2l/src/panels/flshow.cpp | 22 +++++++++++----------- far2l/src/usermenu.cpp | 22 ++++++++++++++-------- 4 files changed, 53 insertions(+), 29 deletions(-) diff --git a/far2l/src/filefilterparams.cpp b/far2l/src/filefilterparams.cpp index cfec835e8..2177754b7 100644 --- a/far2l/src/filefilterparams.cpp +++ b/far2l/src/filefilterparams.cpp @@ -49,6 +49,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "pick_color.hpp" #include "datetime.hpp" #include "strmix.hpp" +#include "config.hpp" FileFilterParams::FileFilterParams() { @@ -637,9 +638,16 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P HighlightDataColor *hl = &fphlstate->hl; size_t filenameexamplelen = wcslen(Msg::HighlightExample1); size_t freespace = irect.Right - irect.Left - filenameexamplelen - 2; - size_t ng = freespace, mcl; - mcl = StrSizeOfCells(hl->Mark, hl->MarkLen, ng, false); + size_t ng = freespace; + size_t mcl = StrSizeOfCells(hl->Mark, hl->MarkLen, ng, false); ng = StrCellsCount( hl->Mark, mcl ); + + size_t prews = std::min(Opt.MinFilenameIndentation, Opt.MaxFilenameIndentation); + if (ng < prews) + prews -= ng; + else + prews = 0; + uint64_t ColorB = FarColorToReal(COL_PANELBOX); for (int i = 0; i < 4; i++) { @@ -669,12 +677,18 @@ LONG_PTR WINAPI FileFilterConfigDlgProc(HANDLE hDlg, int Msg, int Param1, LONG_P x++; Text(x, y, ColorM, hl->Mark, mcl); x += ng; + + if (prews) { + Text(L' ', prews); + x += prews; + } + Text(x, y, ColorF, Msg::HighlightExample1, filenameexamplelen); x += filenameexamplelen; ColorF &= (0xFFFFFFFFFFFFFFFF ^ (COMMON_LVB_STRIKEOUT | COMMON_LVB_UNDERSCORE)); - Text(L' ', ColorF, freespace-ng); + Text(L' ', ColorF, freespace-(ng + prews)); - x += (freespace - ng); + x += (freespace - (ng + prews)); Text(x, y, ColorB, VerticalLine1, 1); } diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index 1bd4465f3..b1a3c0dbe 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -528,8 +528,12 @@ class HighlightFilesChunk : protected Threaded } } - if (Colors.MarkLen > _MarkLM && Colors.MarkLen <= Opt.MaxFilenameIndentation) - _MarkLM = Colors.MarkLen; + if (Colors.MarkLen) { + size_t ncells = StrCellsCount( Colors.Mark, Colors.MarkLen ); + + if (ncells > _MarkLM && ncells <= Opt.MaxFilenameIndentation) + _MarkLM = ncells; + } fli.ColorsPtr = PooledHighlightDataColor(Colors); } @@ -993,14 +997,14 @@ static void SaveFilter(FileFilterParams *CurHiData, ConfigWriter &cfg_writer, bo { // Save Mark str FARString strMark = L""; - DWORD dwMarkChar = (hl.MarkLen == 1) ? hl.Mark[0] : 0; +// DWORD dwMarkChar = (hl.MarkLen == 1) ? hl.Mark[0] : 0; + DWORD dwMarkChar = 0; dwMarkChar |= (0xFF0000 * (hl.Flags & HL_FLAGS_MARK_INHERIT)); cfg_writer.SetUInt(HLS.MarkChar, dwMarkChar); - if (hl.MarkLen > 1) - strMark = hl.Mark; - +// if (hl.MarkLen > 1) + strMark = hl.Mark; cfg_writer.SetString(HLS.MarkStr, strMark); } diff --git a/far2l/src/panels/flshow.cpp b/far2l/src/panels/flshow.cpp index e8f4ba6c8..201766e2e 100644 --- a/far2l/src/panels/flshow.cpp +++ b/far2l/src/panels/flshow.cpp @@ -948,13 +948,13 @@ void FileList::ShowList(int ShowStatus, int StartColumn) } #if 1 { /// Draw mark str - size_t padlen = std::min(Opt.MinFilenameIndentation, Opt.MaxFilenameIndentation); + size_t prews = std::min(Opt.MinFilenameIndentation, Opt.MaxFilenameIndentation); if (Opt.ShowFilenameMarks && Opt.Highlight ) { const HighlightDataColor *const hl = ListData[ListPos]->ColorsPtr; - if (Opt.FilenameMarksAllign && MarkLM > padlen) - padlen = std::min(MarkLM, (size_t)Opt.MaxFilenameIndentation); + if (Opt.FilenameMarksAllign && MarkLM > prews) + prews = std::min(MarkLM, (size_t)Opt.MaxFilenameIndentation); if (hl->MarkLen && Width > 2) { const uint64_t OldColor = GetColor(); @@ -964,10 +964,10 @@ void FileList::ShowList(int ShowStatus, int StartColumn) ng = StrCellsCount( hl->Mark, outlen ); Width -= ng; - if (ng < padlen) - padlen -= ng; + if (ng < prews) + prews -= ng; else - padlen = 0; + prews = 0; if (!ShowStatus) SetShowColor(ListPos, HIGHLIGHTCOLORTYPE_MARKSTR); @@ -977,15 +977,15 @@ void FileList::ShowList(int ShowStatus, int StartColumn) } } - if (!ShowStatus && padlen && Width > 2) { - if (padlen > (size_t)Width) { - padlen = Width; + if (!ShowStatus && prews && Width > 2) { + if (prews >= (size_t)Width) { + prews = Width; Width = 0; } else - Width -= padlen; + Width -= prews; - Text(L' ', padlen); + Text(L' ', prews); } } /// Draw mark str #endif diff --git a/far2l/src/usermenu.cpp b/far2l/src/usermenu.cpp index f5efbeb83..b0ea199ba 100644 --- a/far2l/src/usermenu.cpp +++ b/far2l/src/usermenu.cpp @@ -463,7 +463,7 @@ FillUserMenu(VMenu &UserMenu, const wchar_t *MenuKey, int MenuPos, int *FuncPos, } UserMenuItem.SetSelect(NumLines == MenuPos); - UserMenuItem.Flags&= ~LIF_SEPARATOR; + UserMenuItem.Flags &= ~LIF_SEPARATOR; } int ItemPos = UserMenu.AddItem(&UserMenuItem); @@ -473,10 +473,13 @@ FillUserMenu(VMenu &UserMenu, const wchar_t *MenuKey, int MenuPos, int *FuncPos, } } +#if 0 + // Extra empty item MenuItemEx UserMenuItem; UserMenuItem.Clear(); UserMenuItem.SetSelect(NumLines == MenuPos); UserMenu.AddItem(&UserMenuItem); +#endif return NumLines; } @@ -580,28 +583,31 @@ int UserMenu::ProcessSingleMenu(const wchar_t *MenuKey, int MenuPos, const wchar break; case KEY_NUMDEL: case KEY_DEL: - - if (MenuPos < NumLine) + if (NumLine && MenuPos > -1 && MenuPos < NumLine) DeleteMenuRecord(MenuKey, MenuPos); break; case KEY_INS: case KEY_F4: case KEY_SHIFTF4: - case KEY_NUMPAD0: + case KEY_NUMPAD0: { + bool bInsertNew = (Key == KEY_INS || Key == KEY_NUMPAD0); - if (Key != KEY_INS && Key != KEY_NUMPAD0 && MenuPos >= NumLine) + if (!bInsertNew && (MenuPos >= NumLine || MenuPos < 0)) break; + if (bInsertNew && MenuPos < 0) + MenuPos = 0; - EditMenu(MenuKey, MenuPos, NumLine, Key == KEY_INS || Key == KEY_NUMPAD0); + EditMenu(MenuKey, MenuPos, NumLine, bInsertNew); + } break; case KEY_CTRLUP: case KEY_CTRLDOWN: { int Pos = UserMenu.GetSelectPos(); - if (Pos != UserMenu.GetItemCount() - 1) { + if (Pos != UserMenu.GetItemCount()) { if (!(Key == KEY_CTRLUP && !Pos) - && !(Key == KEY_CTRLDOWN && Pos == UserMenu.GetItemCount() - 2)) { + && !(Key == KEY_CTRLDOWN && Pos == UserMenu.GetItemCount() - 1)) { MenuPos = Pos + (Key == KEY_CTRLUP ? -1 : +1); MoveMenuItem(MenuKey, Pos, MenuPos); } From 8842945e83fbf331e94fe81f2b4d9df1bc076ba5 Mon Sep 17 00:00:00 2001 From: anta999 Date: Mon, 16 Sep 2024 17:54:56 +0400 Subject: [PATCH 24/27] ret the prev highlightdata == operator --- far2l/src/hilight.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index b1a3c0dbe..bf7a2840f 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -1063,9 +1063,32 @@ void HighlightFiles::SaveHiData() static bool operator==(const HighlightDataColor &hl1, const HighlightDataColor &hl2) { +#if 0 return !memcmp(&hl1, &hl2, sizeof(HighlightDataColor)); +#else + if (hl1.MarkLen != hl2.MarkLen) + return false; + if (hl1.Flags != hl2.Flags) + return false; + + if (hl1.MarkLen) + if (memcmp(&hl1.Mark[0], &hl2.Mark[0], sizeof(wchar_t) * hl1.MarkLen)) + return false; + + for (size_t i = 0; i < ARRAYSIZE(hl1.Color); ++i) { + for (size_t j = 0; j < ARRAYSIZE(hl1.Color[i]); ++j) { + if (hl1.Color[i][j] != hl2.Color[i][j]) + return false; + if (hl1.Mask[i][j] != hl2.Mask[i][j]) + return false; + } + } + + return true; +#endif } + struct HighlightDataColorHash { size_t operator()(const HighlightDataColor &hl) const From 7b5fb8e330ba75e7cfabc5c4c752ed6bfe2b8308 Mon Sep 17 00:00:00 2001 From: elfmz Date: Mon, 16 Sep 2024 20:55:44 +0300 Subject: [PATCH 25/27] cosmetic --- far2l/src/hilight.cpp | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index bf7a2840f..82ed9e3e6 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -1063,29 +1063,13 @@ void HighlightFiles::SaveHiData() static bool operator==(const HighlightDataColor &hl1, const HighlightDataColor &hl2) { -#if 0 - return !memcmp(&hl1, &hl2, sizeof(HighlightDataColor)); -#else - if (hl1.MarkLen != hl2.MarkLen) + if (hl1.Flags != hl2.Flags || hl1.MarkLen != hl2.MarkLen) return false; - if (hl1.Flags != hl2.Flags) - return false; - - if (hl1.MarkLen) - if (memcmp(&hl1.Mark[0], &hl2.Mark[0], sizeof(wchar_t) * hl1.MarkLen)) - return false; - for (size_t i = 0; i < ARRAYSIZE(hl1.Color); ++i) { - for (size_t j = 0; j < ARRAYSIZE(hl1.Color[i]); ++j) { - if (hl1.Color[i][j] != hl2.Color[i][j]) - return false; - if (hl1.Mask[i][j] != hl2.Mask[i][j]) - return false; - } - } + if (hl1.MarkLen && wmemcmp(&hl1.Mark[0], &hl2.Mark[0], hl1.MarkLen) != 0) + return false; - return true; -#endif + return (hl1.Color == hl2.Color && hl1.Mask == hl2.Mask); } From 44f5601f9e6265fc5bca6da81a8bdab679bdac25 Mon Sep 17 00:00:00 2001 From: spvkgn Date: Tue, 17 Sep 2024 13:20:31 +0500 Subject: [PATCH 26/27] fix bash-completion installation path https://github.com/elfmz/far2l/pull/2381#issuecomment-2354609695 --- bash-completion/CMakeLists.txt | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bash-completion/CMakeLists.txt b/bash-completion/CMakeLists.txt index e773b594c..b8baaa217 100644 --- a/bash-completion/CMakeLists.txt +++ b/bash-completion/CMakeLists.txt @@ -1,4 +1 @@ -if (NOT CMAKE_BASH_COMP_DIR) - set(CMAKE_BASH_COMP_DIR ${CMAKE_XDGDATA_DIR}/bash-completion/completions) -endif() -install(FILES far2l DESTINATION ${CMAKE_BASH_COMP_DIR}) +install(FILES far2l DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions) From d0340a8333845a8d84da15f806f3e23c1b6f0e76 Mon Sep 17 00:00:00 2001 From: elfmz Date: Tue, 17 Sep 2024 22:04:08 +0300 Subject: [PATCH 27/27] fix --- far2l/src/hilight.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/far2l/src/hilight.cpp b/far2l/src/hilight.cpp index 82ed9e3e6..5a6296eda 100644 --- a/far2l/src/hilight.cpp +++ b/far2l/src/hilight.cpp @@ -1069,7 +1069,13 @@ static bool operator==(const HighlightDataColor &hl1, const HighlightDataColor & if (hl1.MarkLen && wmemcmp(&hl1.Mark[0], &hl2.Mark[0], hl1.MarkLen) != 0) return false; - return (hl1.Color == hl2.Color && hl1.Mask == hl2.Mask); + if (memcmp(hl1.Color, hl2.Color, sizeof(hl2.Color)) != 0) + return false; + + if (memcmp(hl1.Mask, hl2.Mask, sizeof(hl2.Mask)) != 0) + return false; + + return true; } @@ -1077,7 +1083,7 @@ struct HighlightDataColorHash { size_t operator()(const HighlightDataColor &hl) const { - size_t out = hl.MarkLen * 0xFFFF; + size_t out = hl.Flags ^ (hl.MarkLen * 0xFFFF); for (size_t i = 0; i < ARRAYSIZE(hl.Color); ++i) { for (size_t j = 0; j < ARRAYSIZE(hl.Color[i]); ++j) {