Skip to content

Commit

Permalink
Quake-mode (#2)
Browse files Browse the repository at this point in the history
* Added quake mode (Drop Down mode)

* Quake mode (optional)

* changed quake_mode=on to quake_mode=false
  • Loading branch information
sodomon2 authored Jan 31, 2021
1 parent 865f9db commit cf08711
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ make moonterm

## Dependencies

- [Lua](https://www.lua.org/download.html)
- [Lua](https://www.lua.org/download.html)
- [Lua-lgi](https://github.com/pavouk/lgi)
- [VTE](https://github.com/GNOME/vte)
- [Keybinder](https://github.com/kupferlauncher/keybinder/) **optional: required by quake-mode**
38 changes: 37 additions & 1 deletion libraries/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function utils:create_config(dir,filename)
local filename = ('%s/%s'):format(config_dir, filename)
if not utils:isfile(filename) then
os.execute( ('mkdir -p %s'):format(config_dir) )
text = ("[moonterm]\ninterpreter=%s\n"):format(shell)
text = ("[moonterm]\ninterpreter=%s\nquake_mode=false\n"):format(shell)
file = assert(io.open(filename,'w'), 'Error loading file : ' .. filename)
file:write(text)
file:close()
Expand Down Expand Up @@ -41,4 +41,40 @@ function utils:path_name(uri)
return result
end

function utils:print_r(t, fd)
fd = fd or io.stdout
local function print(str) str = str or "" fd:write(str.."\n") end
local print_r_cache={}
local function sub_print_r(t,indent)
if (print_r_cache[tostring(t)]) then
print(indent.."*"..tostring(t))
else
print_r_cache[tostring(t)]=true
if (type(t)=="table") then
for pos,val in pairs(t) do
if (type(val)=="table") then
print(indent.."["..pos.."] => "..tostring(t).." {")
sub_print_r(val,indent..string.rep(" ",string.len(pos)+8))
print(indent..string.rep(" ",string.len(pos)+6).."}")
elseif (type(val)=="string") then
print(indent.."["..pos..'] => "'..val..'"')
else
print(indent.."["..pos.."] => "..tostring(val))
end
end
else
print(indent..tostring(t))
end
end
end
if (type(t)=="table") then
print(tostring(t).." {")
sub_print_r(t," ")
print("}")
else
sub_print_r(t," ")
end
print()
end

return utils
4 changes: 4 additions & 0 deletions moonterm.lua
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ utils:create_config('moonterm','moonterm.ini')
dir = ('%s/moonterm'):format(GLib.get_user_config_dir())
conf = inifile:load(('%s/moonterm.ini'):format(dir))

if conf.moonterm.quake_mode == true then
Keybinder = lgi.require('Keybinder', '3.0')
end

-- MoonTerm
require('src.moonterm-app')
require('src.moonterm-menu')
Expand Down
9 changes: 8 additions & 1 deletion src/moonterm-app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,14 @@ function app:on_activate()
main_window:set_titlebar(headerbar)
main_window.child.scroll:add(term)
main_window.set_icon_name(main_window,'terminal')
main_window:show_all()
if conf.moonterm.quake_mode == true then
main_window.decorated = false
main_window:resize(Gdk.Screen.width(), Gdk.Screen.height()*(50/100))
main_window:set_position(0)
Keybinder.init()
else
main_window:show_all()
end
self:add_window(main_window)
end

13 changes: 13 additions & 0 deletions src/moonterm-dialog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ content = Gtk.Box {
id = 'entry_interpreter'
}
},
Gtk.Box {
orientation = 'HORIZONTAL',
spacing = 5,
border_width = 5,
Gtk.Label {
label = " Quake Mode : "
},
Gtk.Switch {
id = 'quake_switch'
}
},
Gtk.Box {
orientation = 'HORIZONTAL',
homogeneous = true,
Expand All @@ -34,6 +45,7 @@ content = Gtk.Box {
label = "Apply",
on_clicked = function ()
conf.moonterm.interpreter = content.child.entry_interpreter.text
conf.moonterm.quake_mode = content.child.quake_switch:get_active()
inifile:save(('%s/moonterm.ini'):format(dir), conf)
dialog_config:hide()
end
Expand All @@ -48,3 +60,4 @@ content = Gtk.Box {

dialog_config:get_content_area():add(content)
content.child.entry_interpreter:grab_focus()
content.child.quake_switch:set_active(conf.moonterm.quake_mode)
17 changes: 17 additions & 0 deletions src/moonterm-keybinds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ function toggle_fullscreen()
end
end

function quake()
if conf.moonterm.quake_mode == true then
visible = not visible
if visible then
main_window:show_all()
main_window.skip_taskbar_hint = true
else
main_window:hide()
main_window.skip_taskbar_hint = false
end
end
end

if conf.moonterm.quake_mode == true then
Keybinder.bind("F12",quake)
end

keybindings = {
-- alphanumeric keys
{
Expand Down

0 comments on commit cf08711

Please sign in to comment.