-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint.lua
More file actions
51 lines (47 loc) · 1.34 KB
/
print.lua
File metadata and controls
51 lines (47 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
local U = sh.sharedUtils
local function WriteConsole (value)
local str = assert(U.safe_tostring(value))
assert(win.WriteConsole(str))
end
local function _print (...)
far.Text() --https://bugs.farmanager.com/view.php?id=3524
local n = select("#", ...)
if n>0 then
WriteConsole(...)
for i=2,n do
WriteConsole("\t")
WriteConsole(select(i, ...))
end
end
WriteConsole("\n")
end
local C = far.Colors
local F = far.Flags
local function printPrompt (str)
local cPrefix = far.AdvControl(F.ACTL_GETCOLOR, C.COL_COMMANDLINEPREFIX)
local cCmdline = far.AdvControl(F.ACTL_GETCOLOR, C.COL_COMMANDLINE)
local Y = far.AdvControl(F.ACTL_GETCURSORPOS).Y
local prefix,cmdline = str:match"^(.->)(.+)"
far.Text(0, Y, cPrefix, prefix)
far.Text(prefix:len(), Y, cCmdline, cmdline)
far.Text()
_print()
end
local function print_wrapper (...)
U.GetUserScreen()
if sh._shared.prnPrompt then
--_print(sh._shared.prnPrompt)
printPrompt(sh._shared.prnPrompt)
sh._shared.prnPrompt = false
end
_print(...)
end
local print = print_wrapper
if _cmdline=="" then
print "Analog of the standard Lua function print, based on win.WriteConsole."
print "Outputs text to a buffer under panels (panels are turned off and on automatically after the script finishes)."
elseif _cmdline then
print(...)
else --export
return print
end