mirror of
https://github.com/edubart/otclient.git
synced 2025-10-14 11:34:54 +02:00
add ui padding
This commit is contained in:
@@ -2,4 +2,9 @@ function dumpWidgets()
|
||||
for i=1,rootWidget:getChildCount() do
|
||||
print(rootWidget:getChildByIndex(i):getId())
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function drawDebugBoxes(enable)
|
||||
if enable == nil then enable = true end
|
||||
g_ui.setDebugBoxesDrawing(enable)
|
||||
end
|
||||
|
@@ -82,29 +82,11 @@ local function completeCommand()
|
||||
end
|
||||
end
|
||||
|
||||
local function onCommandLineKeyPress(widget, keyCode, keyText, keyboardModifiers)
|
||||
if keyboardModifiers == KeyboardNoModifier then
|
||||
-- execute current command
|
||||
if keyCode == KeyReturn or keyCode == KeyEnter then
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
Terminal.executeCommand(currentCommand)
|
||||
commandLineEdit:clearText()
|
||||
return true
|
||||
-- navigate history up
|
||||
elseif keyCode == KeyUp then
|
||||
navigateCommand(1)
|
||||
return true
|
||||
-- navigate history down
|
||||
elseif keyCode == KeyDown then
|
||||
navigateCommand(-1)
|
||||
return true
|
||||
-- complete command
|
||||
elseif keyCode == KeyTab then
|
||||
completeCommand()
|
||||
return true
|
||||
end
|
||||
end
|
||||
return false
|
||||
local function doCommand()
|
||||
local currentCommand = commandLineEdit:getText()
|
||||
Terminal.executeCommand(currentCommand)
|
||||
commandLineEdit:clearText()
|
||||
return true
|
||||
end
|
||||
|
||||
local function onLog(level, message, time)
|
||||
@@ -128,7 +110,11 @@ function Terminal.init()
|
||||
Hotkeys.bind('Ctrl+T', Terminal.toggle)
|
||||
|
||||
commandLineEdit = terminalWidget:getChildById('commandLineEdit')
|
||||
connect(commandLineEdit, { onKeyPress = onCommandLineKeyPress })
|
||||
Hotkeys.bind('Up', function() navigateCommand(1) end, commandLineEdit)
|
||||
Hotkeys.bind('Down', function() navigateCommand(-1) end, commandLineEdit)
|
||||
Hotkeys.bind('Tab', completeCommand, commandLineEdit)
|
||||
Hotkeys.bind('Enter', doCommand, commandLineEdit)
|
||||
Hotkeys.bind('Return', doCommand, commandLineEdit)
|
||||
|
||||
terminalBuffer = terminalWidget:getChildById('terminalBuffer')
|
||||
Logger.setOnLog(onLog)
|
||||
@@ -171,7 +157,7 @@ function Terminal.addLine(text, color)
|
||||
local label = createWidget('TerminalLabel', terminalBuffer)
|
||||
label:setId('terminalLabel' .. numLines)
|
||||
label:setText(text)
|
||||
label:setForegroundColor(color)
|
||||
label:setColor(color)
|
||||
|
||||
-- delete old lines if needed
|
||||
if numLines > MaxLogLines then
|
||||
@@ -182,6 +168,7 @@ function Terminal.addLine(text, color)
|
||||
end
|
||||
|
||||
function Terminal.executeCommand(command)
|
||||
if command == nil or #command == 0 then return end
|
||||
-- detect and convert commands with simple syntax
|
||||
local realCommand
|
||||
if commandEnv[command] then
|
||||
|
Reference in New Issue
Block a user