Skip to content

Commit 0bce84e

Browse files
committed
library/lua/dfhack.lua interactive interpreter banner: highlight keywords
When the interactive interpreter is started, highlight the various commands and keywords in yellow. This includes banner and the 'Type quit to exit interactive lua interpreter.' message.
1 parent bcb22b5 commit 0bce84e

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

library/lua/dfhack.lua

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -845,18 +845,26 @@ function dfhack.interpreter(prompt,hfile,env)
845845
return nil, 'not interactive'
846846
end
847847

848-
print("Type quit to exit interactive lua interpreter.")
848+
local function print_keyword(pre, keyword, post)
849+
dfhack.color(COLOR_RESET)
850+
if pre ~= nil then dfhack.print(pre) end
851+
dfhack.color(COLOR_YELLOW)
852+
dfhack.print(keyword)
853+
dfhack.color(COLOR_RESET)
854+
if post ~= nil then print(post) end
855+
end
856+
print_keyword("Type ", "quit", " to exit interactive lua interpreter.")
849857

850858
if print_banner then
851-
print("Shortcuts:\n"..
852-
" '= foo' => '_1,_2,... = foo'\n"..
853-
" '! foo' => 'print(foo)'\n"..
854-
" '~ foo' => 'printall(foo)'\n"..
855-
" '^ foo' => 'printall_recurse(foo)'\n"..
856-
" '@ foo' => 'printall_ipairs(foo)'\n"..
857-
"All of these save the first result as '_'.")
859+
print("Shortcuts:")
860+
print_keyword(" '", "= foo", "' => '_1,_2,... = foo'")
861+
print_keyword(" '", "! foo", "' => 'print(foo)'")
862+
print_keyword(" '", "~ foo", "' => 'printall(foo)'")
863+
print_keyword(" '", "^ foo", "' => 'printall_recurse(foo)'")
864+
print_keyword(" '", "@ foo", "' => 'printall_ipairs(foo)'")
865+
print_keyword("All of these save the first result as '", "_", "'.")
858866
print("These keywords refer to the currently-selected object in the game:")
859-
print(" unit item plant building bld job workshop_job wsjob screen scr")
867+
print_keyword(" ", "unit item plant building bld job workshop_job wsjob screen scr", "")
860868
print_banner = false
861869
end
862870

0 commit comments

Comments
 (0)