Skip to content

Commit

Permalink
LuaFAR: add new mode (4) to editor.GetString (only numeric values are…
Browse files Browse the repository at this point in the history
… returned).
  • Loading branch information
shmuz committed Apr 9, 2024
1 parent ba352c2 commit b83e7d9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
11 changes: 6 additions & 5 deletions enc/enc_lua/luafar_manual.tsi
Original file line number Diff line number Diff line change
Expand Up @@ -3954,7 +3954,7 @@ id=31
lv=2
dt=Text
nm=editor.GetString
mtime=3682770766
mtime=3921827714
<article>
#_**Note:**
#_ This function is an extension over its prototype in Far API.
Expand All @@ -3980,10 +3980,11 @@ mtime=3682770766
#_
#_**Description:**
#_ The function's behavior depends on its *Mode* argument:
#_ Mode: 0 = returns: table LineInfo; changes current position: no
#_ 1 = returns: table LineInfo; changes current position: yes
#_ 2 = returns: StringText,StringEOL; changes current position: yes
#_ 3 = returns: StringText,StringEOL; changes current position: no
#_ Mode: 0 = returns: table LineInfo; changes current position: no
#_ 1 = returns: table LineInfo; changes current position: yes
#_ 2 = returns: StringText,StringEOL; changes current position: yes
#_ 3 = returns: StringText,StringEOL; changes current position: no
#_ 4 = returns: SelStart,SelEnd,StringLength; changes cur. position: no
#_
#_ Modes 1 and 2 have a side effect: the current line position in the Editor
#_ is set to *StringNumber*.
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/_globalinfo.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
function export.GetGlobalInfo()
return {
Version = { 3, 0, 0, 820 },
Version = { 3, 0, 0, 821 },
MinFarVersion = { 3, 0, 0, 6214 },
Guid = win.Uuid("4EBBEFC8-2084-4B7F-94C0-692CE136894D"),
Title = "LuaMacro",
Expand Down
4 changes: 4 additions & 0 deletions plugins/luamacro/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
shmuel 2024-04-09 12:25:58+03:00 - build 821

1. LuaFAR: add new mode (4) to editor.GetString (only numeric values are returned).

shmuel 2024-04-08 00:04:02+03:00 - build 820

1. LuaFAR: refactoring.
Expand Down
9 changes: 8 additions & 1 deletion plugins/luamacro/luafar/service.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ static int _EditorGetString(lua_State *L, int is_wide)
struct EditorGetString egs = {0,0,0,NULL,NULL,0,0};
egs.StructSize = sizeof(egs);

if (mode == 0 || mode == 3)
if (mode == 0 || mode == 3 || mode == 4)
{
egs.StringNumber = line_num;
res = Info->EditorControl(EditorId, ECTL_GETSTRING, 0, &egs) != 0;
Expand All @@ -807,6 +807,13 @@ static int _EditorGetString(lua_State *L, int is_wide)

return 2;
}
else if (mode == 4)
{
lua_pushinteger(L, egs.SelStart+1);
lua_pushinteger(L, egs.SelEnd);
lua_pushinteger(L, egs.StringLength);
return 3;
}
else
{
lua_createtable(L, 0, 6);
Expand Down
2 changes: 1 addition & 1 deletion plugins/luamacro/luafar/version.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include <farversion.hpp>

#define PLUGIN_BUILD 820
#define PLUGIN_BUILD 821

0 comments on commit b83e7d9

Please sign in to comment.