diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a13f8b68..629c8226b 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)
@@ -536,6 +532,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/README.md b/README.md
index 4f78265f4..a8f686cd6 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`,
@@ -111,8 +121,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++`
@@ -173,6 +186,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 control how RAR archives will be handled in multiarc:
`-DUNRAR=bundled` (default) use bundled sources found in multiarc/src/formats/rar/unrar
@@ -214,7 +232,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:
diff --git a/WinPort/src/Backend/WX/wxMain.cpp b/WinPort/src/Backend/WX/wxMain.cpp
index be62bbdf8..3a7dc990c 100644
--- a/WinPort/src/Backend/WX/wxMain.cpp
+++ b/WinPort/src/Backend/WX/wxMain.cpp
@@ -1109,12 +1109,147 @@ 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
+#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, "OnKeyDown: 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 +1368,9 @@ 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: %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());
@@ -1311,7 +1448,12 @@ void WinPortPanel::OnChar( wxKeyEvent& event )
{
ResetTimerIdling();
const auto uni = event.GetUnicodeKey();
- fprintf(stderr, "OnChar: raw=%x code=%x uni=%x (%lc) ts=%lu lke=%u",
+ if (_key_tracker.LastKeydown().GetTimestamp() != event.GetTimestamp()) {
+ fprintf(stderr, "\n");
+ }
+ 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);
diff --git a/WinPort/src/ConsoleInput.cpp b/WinPort/src/ConsoleInput.cpp
index 1168b07eb..2e7ff8dbd 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",
+ 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
+ );
}
}
diff --git a/bash-completion/CMakeLists.txt b/bash-completion/CMakeLists.txt
new file mode 100644
index 000000000..b8baaa217
--- /dev/null
+++ b/bash-completion/CMakeLists.txt
@@ -0,0 +1 @@
+install(FILES far2l DESTINATION ${CMAKE_INSTALL_DATADIR}/bash-completion/completions)
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
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..7ab9f96d3
--- /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) override
+ {
+ 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)
diff --git a/far2l/bootstrap/scripts/farlang.templ.m4 b/far2l/bootstrap/scripts/farlang.templ.m4
index 7cbe9d174..86afeb42d 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
+"Фиксированный отступ имен файлов"
+"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
+"Максимальный отступ имен файлов"
+"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/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