Repository :
https://github.com/FarGroup/FarManager
On branch : master
Link :
https://github.com/FarGroup/FarManager/commit/4eca6ae20cf1f4340cdf704e4d1c1942ac0ce8c4
>---------------------------------------------------------------
commit 4eca6ae20cf1f4340cdf704e4d1c1942ac0ce8c4
Author: Shmuel Zeigerman <
solo...@gmail.com>
Date: Mon Sep 14 19:11:36 2026 +0300
LuaFAR: add aliases fg, bg, ul for ForegroundColor, BackgroundColor, UnderlineColor
>---------------------------------------------------------------
4eca6ae20cf1f4340cdf704e4d1c1942ac0ce8c4
enc/enc_lua/luafar_manual.tsi | 7 ++++++-
plugins/luamacro/_globalinfo.lua | 2 +-
plugins/luamacro/changelog | 4 ++++
plugins/luamacro/luafar/lf_service.c | 37 ++++++++++++++++++++++++++++--------
plugins/luamacro/luafar/lf_version.h | 2 +-
5 files changed, 41 insertions(+), 11 deletions(-)
diff --git a/enc/enc_lua/luafar_manual.tsi b/enc/enc_lua/luafar_manual.tsi
index 5ab6cf466..949b06978 100644
--- a/enc/enc_lua/luafar_manual.tsi
+++ b/enc/enc_lua/luafar_manual.tsi
@@ -6643,7 +6643,7 @@ article id=426 dt=Text ctime=
3508525223 mtime=
3602448047 nm=far.NameToInputRecor
#_{farnametoinputrecord}: $(ENC_URL)/fsf/farnametoinputrecord.html
#_
-article id=427 dt=Text ctime=
3508689565 mtime=3955288580 nm=tFarColor
+article id=427 dt=Text ctime=
3508689565 mtime=3998574563 nm=tFarColor
#_<markdown>
#_**`tFarColor`** is a table with the following predefined fields:
#_
@@ -6652,6 +6652,11 @@ article id=427 dt=Text ctime=
3508689565 mtime=3955288580 nm=tFarColor
#_ BackgroundColor: integer
#_ UnderlineColor: integer
#_
+#_#### Note
+#_LuaFAR functions duplicate the `ForegroundColor`, `BackgroundColor` and `UnderlineColor`
+#_fields as `fg`, `bg` and `ul` on output, and accept these aliases on input.
+#_This is provided as a convenience for those who prefer shorter names;
+#_however, on input, the full names take precedence over their shorter counterparts.
#_
article id=428 dt=Text ctime=
3509050121 mtime=
3509086519 nm=win.ShellExecute
diff --git a/plugins/luamacro/_globalinfo.lua b/plugins/luamacro/_globalinfo.lua
index 17ef79f85..b0bf5ef54 100644
--- a/plugins/luamacro/_globalinfo.lua
+++ b/plugins/luamacro/_globalinfo.lua
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
- Version = { 3, 0, 0, 943 },
+ Version = { 3, 0, 0, 944 },
MinFarVersion = { 3, 0, 0, 6723 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
diff --git a/plugins/luamacro/changelog b/plugins/luamacro/changelog
index 0170a67e7..ff795d594 100644
--- a/plugins/luamacro/changelog
+++ b/plugins/luamacro/changelog
@@ -1,3 +1,7 @@
+shmuel 2026-09-14 19:04:35+03:00 - build 944
+
+1. LuaFAR: add aliases fg, bg, ul for ForegroundColor, BackgroundColor, UnderlineColor.
+
MZK 2026-09-08 22:20:59-04:00 - build
1. Use `curl` and `tar` instead of Powershell cmdlets
diff --git a/plugins/luamacro/luafar/lf_service.c b/plugins/luamacro/luafar/lf_service.c
index aae8ac9dc..b7aab6417 100644
--- a/plugins/luamacro/luafar/lf_service.c
+++ b/plugins/luamacro/luafar/lf_service.c
@@ -476,15 +476,33 @@ int SetKeyBar(lua_State *L, BOOL editor)
return 1;
}
+static COLORREF GetFgBgFromTable(lua_State *L, const char *Names[2])
+{
+ COLORREF ret = 0;
+ for (int i = 0; i < 2; i++) {
+ lua_getfield(L, -1, Names[i]);
+ if (lua_isnumber(L, -1)) {
+ ret = (COLORREF)lua_tonumber(L, -1);
+ i = 2; //to end the loop
+ }
+ lua_pop(L, 1);
+ }
+ return ret;
+}
+
+static const char *FgNames[] = { "ForegroundColor", "fg" };
+static const char *BgNames[] = { "BackgroundColor", "bg" };
+static const char *UlNames[] = { "UnderlineColor", "ul" };
+
int GetFarColor(lua_State *L, int pos, struct FarColor* Color)
{
if (lua_istable(L, pos))
{
lua_pushvalue(L, pos);
Color->Flags = CheckFlagsFromTable(L, -1, "Flags");
- Color->Foreground.ForegroundColor = (COLORREF) GetOptNumFromTable(L, "ForegroundColor", 0);
- Color->Background.BackgroundColor = (COLORREF) GetOptNumFromTable(L, "BackgroundColor", 0);
- Color->Underline.UnderlineColor = (COLORREF) GetOptNumFromTable(L, "UnderlineColor", 0);
+ Color->Foreground.ForegroundColor = GetFgBgFromTable(L, FgNames);
+ Color->Background.BackgroundColor = GetFgBgFromTable(L, BgNames);
+ Color->Underline.UnderlineColor = GetFgBgFromTable(L, UlNames);
Color->Reserved = 0;
lua_pop(L, 1);
return 1;
@@ -504,11 +522,14 @@ int GetFarColor(lua_State *L, int pos, struct FarColor* Color)
void PushFarColor(lua_State *L, const struct FarColor* Color)
{
- lua_createtable(L, 0, 3);
+ lua_createtable(L, 0, 7);
PutFlagsToTable(L, "Flags", Color->Flags);
- PutNumToTable(L, "ForegroundColor", Color->Foreground.ForegroundColor);
- PutNumToTable(L, "BackgroundColor", Color->Background.BackgroundColor);
- PutNumToTable(L, "UnderlineColor", Color->Underline.UnderlineColor);
+ for (int i=0; i < 2; i++)
+ {
+ PutNumToTable(L, FgNames[i], Color->Foreground.ForegroundColor);
+ PutNumToTable(L, BgNames[i], Color->Background.BackgroundColor);
+ PutNumToTable(L, UlNames[i], Color->Underline.UnderlineColor);
+ }
}
void GetOptGuid(lua_State *L, int pos, GUID* target, const GUID* source)
@@ -784,7 +805,7 @@ static int far_Menu(lua_State *L)
Items[SelectIndex-1].Flags |= MIF_SELECTED;
// Break Keys
- intptr_t BreakCode = 0;
+ intptr_t BreakCode = -1;
int NumBreakCodes = 0;
struct FarKey *pBreakKeys = NULL;
intptr_t *pBreakCode = NULL;
diff --git a/plugins/luamacro/luafar/lf_version.h b/plugins/luamacro/luafar/lf_version.h
index 128ba7791..d5036e096 100644
--- a/plugins/luamacro/luafar/lf_version.h
+++ b/plugins/luamacro/luafar/lf_version.h
@@ -1,3 +1,3 @@
#include <farversion.hpp>
-#define PLUGIN_BUILD 943
+#define PLUGIN_BUILD 944