lowercase insert/normal, merge conditionals, code improvements

This commit is contained in:
Kinzie 2024-04-16 08:55:39 +01:00
parent a63895ab93
commit 41373190b4
4 changed files with 11 additions and 13 deletions

View File

@ -34,10 +34,10 @@ err_user_init = failed to initialize user
err_user_uid = failed to set user UID
err_xsessions_dir = failed to find sessions folder
err_xsessions_open = failed to open sessions folder
insert = Insert
insert = insert
login = login
logout = logged out
normal = Normal
normal = normal
numlock = numlock
password = password
restart = reboot

View File

@ -297,7 +297,7 @@ fn getFreeDisplay() !u8 {
return i;
}
fn getXPID(display_num: u8) !i32 {
fn getXPid(display_num: u8) !i32 {
var buf: [15]u8 = undefined;
const file_name = try std.fmt.bufPrint(&buf, "/tmp/.X{d}-lock", .{display_num});
const file = try std.fs.openFileAbsolute(file_name, .{});
@ -411,7 +411,7 @@ fn executeX11Cmd(shell: [*:0]const u8, pw_dir: [*:0]const u8, config: Config, de
// X Server detaches from the process.
// PID can be fetched from /tmp/X{d}.lock
const x_pid = try getXPID(display_num);
const x_pid = try getXPid(display_num);
const xorg_pid = try std.os.fork();
if (xorg_pid == 0) {

View File

@ -36,10 +36,10 @@ err_user_init: []const u8 = "failed to initialize user",
err_user_uid: []const u8 = "failed to set user UID",
err_xsessions_dir: []const u8 = "failed to find sessions folder",
err_xsessions_open: []const u8 = "failed to open sessions folder",
insert: []const u8 = "Insert",
insert: []const u8 = "insert",
login: []const u8 = "login:",
logout: []const u8 = "logged out",
normal: []const u8 = "Normal",
normal: []const u8 = "normal",
numlock: []const u8 = "numlock",
other: []const u8 = "other",
password: []const u8 = "password:",

View File

@ -158,7 +158,7 @@ pub fn main() !void {
defer password.deinit();
var active_input = config.default_input;
var insert_mode: bool = if (config.vi_mode) false else true;
var insert_mode = !config.vi_mode;
// Load last saved username and desktop selection, if any
if (config.load) {
@ -353,11 +353,9 @@ pub fn main() !void {
buffer.drawLabel(lang.login, label_x, label_y + 4);
buffer.drawLabel(lang.password, label_x, label_y + 6);
if (info_line.width > 0) {
if (buffer.box_width > info_line.width) {
const x = buffer.box_x + ((buffer.box_width - info_line.width) / 2);
buffer.drawLabel(info_line.text, x, label_y);
}
if (info_line.width > 0 and buffer.box_width > info_line.width) {
const x = buffer.box_x + ((buffer.box_width - info_line.width) / 2);
buffer.drawLabel(info_line.text, x, label_y);
}
if (!config.hide_key_hints) {
@ -387,7 +385,7 @@ pub fn main() !void {
}
if (config.vi_mode) {
const label_txt = if (!insert_mode) lang.normal else lang.insert;
const label_txt = if (insert_mode) lang.insert else lang.normal;
buffer.drawLabel(label_txt, buffer.box_x, buffer.box_y - 1);
}