Skip to content

Commit

Permalink
Version 2.0!!!
Browse files Browse the repository at this point in the history
Custom interpreter
Custom title
mooterm-dialog.lua => src/mooterm-dialog.lua

add src/moonterm-app.lua
add src/moonterm-popover.lua
add moonterm.desktop
  • Loading branch information
sodomon2 committed Jan 22, 2021
1 parent e0f6f19 commit 75cec5e
Show file tree
Hide file tree
Showing 5 changed files with 107 additions and 53 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ PREFIX ?= /usr/local
DESTDIR ?= $(PREFIX)/bin
DESKTOP_DIR ?= $(PREFIX)/share/applications

SRC = moonterm.lua moonterm-dialog.lua libraries/LIP.lua libraries/utils.lua
SRC = moonterm.lua src/moonterm-dialog.lua src/moonterm-app.lua \
src/moonterm-popover.lua libraries/LIP.lua libraries/utils.lua

moonterm:
$(LUASTATIC) $(SRC) -l$(LUA) -I$(LUA_INCLUDE)
Expand Down
55 changes: 3 additions & 52 deletions moonterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,57 +25,8 @@ dir = ('%s/moonterm'):format(GLib.get_user_config_dir())
conf = inifile:load(('%s/moonterm.ini'):format(dir))

-- MoonTerm
require('moonterm-dialog')

scroll = Gtk.ScrolledWindow()
main_window = Gtk.Window {
width_request = 600,
height_request = 400,
scroll
}

headerbar = Gtk.HeaderBar {
title = 'MoonTerm',
subtitle = 'a simple vte terminal in lua',
show_close_button = true,
Gtk.Button {
visible = true,
on_clicked = function () dialog_config:show_all() end,
Gtk.Image({icon_name = "gtk-justify-fill"})
}
}

interpreter_name = utils:path_name(conf.interpreter.executable)['name']
if conf.interpreter.executable == shell then
headerbar.title = 'Moonterm'
else
headerbar.title = ('Moonterm - %s'):format(interpreter_name)
headerbar.subtitle = ('Moonterm using : %s interpreter'):format(interpreter_name)
end

function term:on_child_exited()
app:quit()
end

function app:on_activate()
font = term:get_font()
--font:set_family("Camingo Code") -- Fix error when " Camingo Code " font is not available
font:set_size(font:get_size() * 1.2)

term:spawn_sync(
Vte.PtyFlags.DEFAULT,
nil,
{ conf.interpreter.executable },
nil,
GLib.SpawnFlags.DEFAULT,
function() end
)
dialog_config.child.entry_interpreter.text = conf.interpreter.executable
main_window:set_titlebar(headerbar)
scroll:add(term)
main_window.set_icon_name(main_window,'terminal')
main_window:show_all()
self:add_window(main_window)
end
require('src.moonterm-popover')
require('src.moonterm-app')
require('src.moonterm-dialog')

app:run()
75 changes: 75 additions & 0 deletions src/moonterm-app.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
--[[--
@package MoonTerm
@filename moonterm-app.lua
@version 1.0
@author Diaz Urbaneja Victor Diego Alejandro <sodomon2@gmail.com>
@date 22.01.2021 01:34:58 -04
--]]

about_window = Gtk.AboutDialog ({
version = '2.0',
copyright = 'The Moonsteal Team\n Copyright © 2021',
comments = 'a minimalist and customizable terminal in lua',
website = 'https://github.com/moonsteal/moonterm'
})

about_window.set_program_name(about_window,'MoonTerm')
about_window.set_logo_icon_name(about_window,'terminal')
about_window.set_website_label(about_window,'Github')
about_window.set_authors(about_window,{
'Díaz Urbaneja Víctor Diego Alejandro',
'The Moonsteal Team'
})

scroll = Gtk.ScrolledWindow()
main_window = Gtk.Window {
width_request = 600,
height_request = 400,
scroll
}

headerbar = Gtk.HeaderBar {
title = 'MoonTerm',
subtitle = 'a simple vte terminal in lua',
show_close_button = true,
Gtk.MenuButton {
visible = true,
popover = popover_menu,
on_clicked = function () popover_menu:show_all() end,
Gtk.Image({icon_name = "gtk-justify-fill"})
}
}

interpreter_name = utils:path_name(conf.interpreter.executable)['name']
if conf.interpreter.executable == shell then
headerbar.title = 'Moonterm'
else
headerbar.title = ('Moonterm - %s'):format(interpreter_name)
headerbar.subtitle = ('Moonterm using : %s interpreter'):format(interpreter_name)
end

function term:on_child_exited()
app:quit()
end

function app:on_activate()
font = term:get_font()
--font:set_family("Camingo Code") -- Fix error when " Camingo Code " font is not available
font:set_size(font:get_size() * 1.2)

term:spawn_sync(
Vte.PtyFlags.DEFAULT,
nil,
{ conf.interpreter.executable },
nil,
GLib.SpawnFlags.DEFAULT,
function() end
)
dialog_config.child.entry_interpreter.text = conf.interpreter.executable
main_window:set_titlebar(headerbar)
scroll:add(term)
main_window.set_icon_name(main_window,'terminal')
main_window:show_all()
self:add_window(main_window)
end

File renamed without changes.
27 changes: 27 additions & 0 deletions src/moonterm-popover.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
--[[--
@package MoonTerm
@filename moonterm-popover.lua
@version 1.0
@autor Diaz Urbaneja Victor Diego Alejandro <sodomon2@gmail.com>
@date 22.01.2021 01:40:09 -04
]]

popover_menu = Gtk.Popover({
Gtk.Box {
orientation = 'VERTICAL',
Gtk.ModelButton {
id = 'btn_preferences',
label = "Preferences",
on_clicked = function () dialog_config:show_all() end,
},
Gtk.ModelButton {
label = "About Moonterm",
on_clicked = function () about_window:run() about_window:hide() end,
},
Gtk.Separator{},
Gtk.ModelButton {
label = "Quit",
on_clicked = function () app:quit() end,
},
},
})

0 comments on commit 75cec5e

Please sign in to comment.