Unify style and indentation.

This commit is contained in:
Xinhao Yuan 2021-02-26 20:39:59 -05:00
parent ee08eecb49
commit 76d2aa5776
4 changed files with 989 additions and 992 deletions

View File

@ -151,15 +151,15 @@ function module.create(data)
local label_size = dpi(30)
local info_size = dpi(60)
-- colors are in rgba
local border_color = with_alpha(api.gears.color(
api.beautiful.machi_editor_border_color or api.beautiful.border_focus),
api.beautiful.machi_editor_border_opacity or 0.75)
local active_color = with_alpha(api.gears.color(
api.beautiful.machi_editor_active_color or api.beautiful.bg_focus),
api.beautiful.machi_editor_active_opacity or 0.5)
local open_color = with_alpha(api.gears.color(
api.beautiful.machi_editor_open_color or api.beautiful.bg_normal),
api.beautiful.machi_editor_open_opacity or 0.5)
local border_color = with_alpha(
gears.color(beautiful.machi_editor_border_color or beautiful.border_focus),
beautiful.machi_editor_border_opacity or 0.75)
local active_color = with_alpha(
gears.color(beautiful.machi_editor_active_color or beautiful.bg_focus),
beautiful.machi_editor_active_opacity or 0.5)
local open_color = with_alpha(
gears.color(beautiful.machi_editor_open_color or beautiful.bg_normal),
beautiful.machi_editor_open_opacity or 0.5)
local closed_color = open_color
if to_save == nil then

View File

@ -3,19 +3,16 @@ local machi = {
engine = require((...):match("(.-)[^%.]+$") .. "engine"),
}
local api = {
client = client,
beautiful = require("beautiful"),
wibox = require("wibox"),
awful = require("awful"),
screen = require("awful.screen"),
layout = require("awful.layout"),
naughty = require("naughty"),
gears = require("gears"),
lgi = require("lgi"),
dpi = require("beautiful.xresources").apply_dpi,
local capi = {
client = client
}
local beautiful = require("beautiful")
local wibox = require("wibox")
local awful = require("awful")
local gears = require("gears")
local lgi = require("lgi")
local dpi = require("beautiful.xresources").apply_dpi
local gtimer = require("gears.timer")
local ERROR = 2
@ -44,35 +41,35 @@ end
local function with_alpha(col, alpha)
local r, g, b
_, r, g, b, _ = col:get_rgba()
return api.lgi.cairo.SolidPattern.create_rgba(r, g, b, alpha)
return lgi.cairo.SolidPattern.create_rgba(r, g, b, alpha)
end
function module.start(c, exit_keys)
local tablist_font_desc = api.beautiful.get_merged_font(
api.beautiful.font, api.dpi(10))
local font_color = with_alpha(api.gears.color(api.beautiful.fg_normal), 1)
local font_color_hl = with_alpha(api.gears.color(api.beautiful.fg_focus), 1)
local label_size = api.dpi(30)
local border_color = with_alpha(api.gears.color(
api.beautiful.machi_switcher_border_color or api.beautiful.border_focus),
api.beautiful.machi_switcher_border_opacity or 0.25)
local border_color_hl = with_alpha(api.gears.color(
api.beautiful.machi_switcher_border_hl_color or api.beautiful.border_focus),
api.beautiful.machi_switcher_border_hl_opacity or 0.75)
local fill_color = with_alpha(api.gears.color(
api.beautiful.machi_switcher_fill_color or api.beautiful.bg_normal),
api.beautiful.machi_switcher_fill_opacity or 0.25)
local box_bg = with_alpha(api.gears.color(
api.beautiful.machi_switcher_box_bg or api.beautiful.bg_normal),
api.beautiful.machi_switcher_box_opacity or 0.85)
local fill_color_hl = with_alpha(api.gears.color(
api.beautiful.machi_switcher_fill_color_hl or api.beautiful.bg_focus),
api.beautiful.machi_switcher_fill_hl_opacity or 1)
local tablist_font_desc = beautiful.get_merged_font(
beautiful.font, dpi(10))
local font_color = with_alpha(gears.color(beautiful.fg_normal), 1)
local font_color_hl = with_alpha(gears.color(beautiful.fg_focus), 1)
local label_size = dpi(30)
local border_color = with_alpha(
gears.color(beautiful.machi_switcher_border_color or beautiful.border_focus),
beautiful.machi_switcher_border_opacity or 0.25)
local border_color_hl = with_alpha(
gears.color(beautiful.machi_switcher_border_hl_color or beautiful.border_focus),
beautiful.machi_switcher_border_hl_opacity or 0.75)
local fill_color = with_alpha(
gears.color(beautiful.machi_switcher_fill_color or beautiful.bg_normal),
beautiful.machi_switcher_fill_opacity or 0.25)
local box_bg = with_alpha(
gears.color(beautiful.machi_switcher_box_bg or beautiful.bg_normal),
beautiful.machi_switcher_box_opacity or 0.85)
local fill_color_hl = with_alpha(
gears.color(beautiful.machi_switcher_fill_color_hl or beautiful.bg_focus),
beautiful.machi_switcher_fill_hl_opacity or 1)
-- for comparing floats
local threshold = 0.1
local traverse_radius = api.dpi(5)
local traverse_radius = dpi(5)
local screen = c and c.screen or api.screen.focused()
local screen = c and c.screen or awful.screen.focused()
local tag = screen.selected_tag
local layout = tag.layout
local gap = tag.gap
@ -86,7 +83,7 @@ function module.start(c, exit_keys)
return
end
local infobox = api.wibox({
local infobox = wibox({
screen = screen,
x = screen.workarea.x,
y = screen.workarea.y,
@ -224,10 +221,10 @@ function module.start(c, exit_keys)
if #tablist > 0 then
local a = areas[active_area]
local pl = api.lgi.Pango.Layout.create(cr)
local pl = lgi.Pango.Layout.create(cr)
pl:set_font_description(tablist_font_desc)
local vpadding = api.dpi(10)
local vpadding = dpi(10)
local list_height = vpadding
local list_width = 2 * vpadding
local exts = {}
@ -237,8 +234,8 @@ function module.start(c, exit_keys)
pl:set_text(label)
local w, h
w, h = pl:get_size()
w = w / api.lgi.Pango.SCALE
h = h / api.lgi.Pango.SCALE
w = w / lgi.Pango.SCALE
h = h / lgi.Pango.SCALE
local ext = { width = w, height = h, x_bearing = 0, y_bearing = 0 }
exts[#exts + 1] = ext
list_height = list_height + ext.height + vpadding
@ -295,16 +292,16 @@ function module.start(c, exit_keys)
["d"] = "Right",
}
api.awful.client.focus.history.disable_tracking()
awful.client.focus.history.disable_tracking()
local kg
local function exit()
api.awful.client.focus.history.enable_tracking()
if api.client.focus then
api.client.emit_signal("focus", api.client.focus)
awful.client.focus.history.enable_tracking()
if capi.client.focus then
capi.client.emit_signal("focus", capi.client.focus)
end
infobox.visible = false
api.awful.keygrabber.stop(kg)
awful.keygrabber.stop(kg)
end
local function handle_key(mod, key, event)
@ -467,7 +464,7 @@ function module.start(c, exit_keys)
c:emit_signal("request::activate", "mouse.move", {raise=false})
c:raise()
api.layout.arrange(screen)
awful.layout.arrange(screen)
elseif shift then
-- move the window
if in_draft then
@ -479,7 +476,7 @@ function module.start(c, exit_keys)
end
c:emit_signal("request::activate", "mouse.move", {raise=false})
c:raise()
api.layout.arrange(screen)
awful.layout.arrange(screen)
tablist = nil
end
@ -488,7 +485,7 @@ function module.start(c, exit_keys)
-- move the focus
if #tablist > 0 and tablist[1] ~= c then
c = tablist[1]
api.client.focus = c
capi.client.focus = c
end
end
@ -536,7 +533,7 @@ function module.start(c, exit_keys)
else
c.machi_draft = not c.machi_draft
end
api.layout.arrange(screen)
awful.layout.arrange(screen)
elseif key == "Escape" or key == "Return" then
exit()
else
@ -544,7 +541,7 @@ function module.start(c, exit_keys)
end
end
kg = api.awful.keygrabber.run(
kg = awful.keygrabber.run(
function (...)
ok, _ = pcall(handle_key, ...)
if not ok then exit() end