diff options
| author | 2025-06-02 12:47:45 -0400 | |
|---|---|---|
| committer | 2025-06-02 12:50:22 -0400 | |
| commit | 7ad2cd0d2204bb9f6ec65a2af9a0d4518f5c62d1 (patch) | |
| tree | 7ee5ffb2ef89d34f7a0a5209edd2137a67e07e89 | |
| parent | f2318df4bfda763eafb6d535175e246ad18ac6a3 (diff) | |
| download | mauri-7ad2cd0d2204bb9f6ec65a2af9a0d4518f5c62d1.tar.gz mauri-7ad2cd0d2204bb9f6ec65a2af9a0d4518f5c62d1.tar.bz2 mauri-7ad2cd0d2204bb9f6ec65a2af9a0d4518f5c62d1.zip | |
Changes from deps
Signed-off-by: Andrew Opalach <andrew@akon.city>
| -rw-r--r-- | flake.lock | 6 | ||||
| -rwxr-xr-x | scripts/line_count.sh | 3 | ||||
| -rw-r--r-- | src/gl.cc | 7 | ||||
| -rw-r--r-- | src/log.h | 6 | ||||
| -rw-r--r-- | src/mauri.cc | 36 | ||||
| -rw-r--r-- | src/objects/pass.cc | 3 | ||||
| -rw-r--r-- | subprojects/libalabaster.wrap | 2 | ||||
| -rw-r--r-- | subprojects/libnaunet.wrap | 2 | ||||
| -rw-r--r-- | subprojects/stela.wrap | 2 | ||||
| -rw-r--r-- | taro/config.h | 8 | ||||
| -rw-r--r-- | taro/daemon.c | 42 | ||||
| -rw-r--r-- | taro/db.c | 8 | ||||
| -rw-r--r-- | taro/file_ext.c | 2 | ||||
| -rw-r--r-- | taro/ui.c | 60 |
14 files changed, 111 insertions, 76 deletions
@@ -19,11 +19,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1743315132, - "narHash": "sha256-6hl6L/tRnwubHcA4pfUUtk542wn2Om+D4UnDhlDW9BE=", + "lastModified": 1748693115, + "narHash": "sha256-StSrWhklmDuXT93yc3GrTlb0cKSS0agTAxMGjLKAsY8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "52faf482a3889b7619003c0daec593a1912fddc1", + "rev": "910796cabe436259a29a72e8d3f5e180fc6dfacc", "type": "github" }, "original": { diff --git a/scripts/line_count.sh b/scripts/line_count.sh index 8de6ef8..9bba4dd 100755 --- a/scripts/line_count.sh +++ b/scripts/line_count.sh @@ -1,2 +1,3 @@ #! /usr/bin/env sh -find ./src ./taro/src -type f -exec wc -l {} + +export LC_ALL="C" +find ./src ./taro -type f -exec loccount {} + @@ -473,7 +473,7 @@ RenderFramebuffer::RenderFramebuffer(s32 width, s32 height, f32 scale) glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, this->texture->id, 0); - GLenum attatchment[] = {GL_COLOR_ATTACHMENT0}; + GLenum attatchment[] = { GL_COLOR_ATTACHMENT0 }; glDrawBuffers(1, attatchment); } @@ -488,14 +488,15 @@ auto RenderFramebuffer::blit(u32 dest, s32 width, s32 height) -> void if (!context()->is_draw_enabled()) return; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, dest); glBindFramebuffer(GL_READ_FRAMEBUFFER, this->id); - glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, GL_COLOR_BUFFER_BIT, GL_NEAREST); + GLbitfield mask = GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT; + glBlitFramebuffer(0, 0, width, height, 0, 0, width, height, mask, GL_NEAREST); } auto RenderFramebuffer::clear(vec4 color) -> void { if (!context()->is_draw_enabled()) return; glBindFramebuffer(GL_DRAW_FRAMEBUFFER, this->id); - glClearBufferfv(GL_COLOR, 0, glm::value_ptr(color)); + glClearBufferfv(GL_COLOR | GL_DEPTH, 0, glm::value_ptr(color)); } RenderFramebuffer::~RenderFramebuffer() @@ -5,4 +5,10 @@ extern "C" { #include <al/log.h> } +#define info(fmt, ...) log_info(fmt, ##__VA_ARGS__) +#define warn(fmt, ...) log_warn(fmt, ##__VA_ARGS__) +#define error(fmt, ...) log_error(fmt, ##__VA_ARGS__) +#define debug(fmt, ...) log_debug(fmt, ##__VA_ARGS__) +#define trace(fmt, ...) log_trace(fmt, ##__VA_ARGS__) + #endif // _LOG_H diff --git a/src/mauri.cc b/src/mauri.cc index 9351320..6e0bcbf 100644 --- a/src/mauri.cc +++ b/src/mauri.cc @@ -28,18 +28,18 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 { (void)argc; (void)argv; - janus::ArgParser args = *(janus::ArgParser *)extra; + janus::ArgParser *args = (janus::ArgParser *)extra; - if (!(args.found("package") ^ args.found("directory"))) + if (!(args->found("package") ^ args->found("directory"))) { - al_printf("%s\n", args.helptext.c_str()); + al_printf("%s\n", args->helptext.c_str()); return EXIT_FAILURE; } s32 width = 720; s32 height = 480; - if (args.found("width")) width = args.getInt("width"); - if (args.found("height")) height = args.getInt("height"); + if (args->found("width")) width = args->getInt("width"); + if (args->found("height")) height = args->getInt("height"); if (width == 0 || height == 0) { error("invalid width and/or height in arguments"); @@ -48,36 +48,36 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 s32 xoffset; s32 yoffset; - if (sscanf(args.getString("offset").c_str(), "%d,%d", &xoffset, &yoffset) != 2) + if (sscanf(args->getString("offset").c_str(), "%d,%d", &xoffset, &yoffset) != 2) { error("invalid offset in arguments"); return EXIT_FAILURE; } bool gifscene = false; - if (args.found("package")) + if (args->found("package")) { - std::string package_path = args.getString("package"); + std::string package_path = args->getString("package"); size_t slash = package_path.rfind("/"); std::string filename; if (slash != std::string::npos) filename = package_path.substr(slash + 1); else filename = package_path; gifscene = filename == "gifscene.pkg"; - if (!asset_manager()->arm_package(package_path, args.found("target"))) + if (!asset_manager()->arm_package(package_path, args->found("target"))) { return EXIT_FAILURE; } } - if (args.found("directory")) + if (args->found("directory")) { - asset_manager()->prepare_output = args.found("target"); - asset_manager()->add_search_directory(args.getString("directory")); + asset_manager()->prepare_output = args->found("target"); + asset_manager()->add_search_directory(args->getString("directory")); } - if (args.found("assets")) + if (args->found("assets")) { - asset_manager()->add_search_directory(args.getString("assets")); + asset_manager()->add_search_directory(args->getString("assets")); } Scene *scene = Scene::parse(gifscene ? "gifscene.json" : "scene.json"); @@ -89,7 +89,7 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 height = scene->height; } - if (args.getFlag("scale")) + if (args->getFlag("scale")) { f32 ratio = scene->width / (f32)scene->height; if (ratio > 1.f) height = width / ratio; @@ -97,7 +97,7 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 } Context *new_context = new Context(); - if (!new_context->create_window(width, height, "mauri", args.getString("monitor"))) + if (!new_context->create_window(width, height, "mauri", args->getString("monitor"))) { return EXIT_FAILURE; } @@ -116,7 +116,7 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 u64 duration = nn_get_timestamp() - begin; info("scene loaded in %.2fs", duration / 1000000.f); - if (asset_manager()->prepare_output) asset_manager()->dump(args.getString("target")); + if (asset_manager()->prepare_output) asset_manager()->dump(args->getString("target")); else engine->run(); delete scene; @@ -124,7 +124,7 @@ auto window_system_main(u32 argc, str *argv, void *extra) -> s32 unload_shaders(); - if (args.found("package")) asset_manager()->unload_package(); + if (args->found("package")) asset_manager()->unload_package(); context()->close_window(); set_context(nullptr); diff --git a/src/objects/pass.cc b/src/objects/pass.cc index dc19378..e2dc02d 100644 --- a/src/objects/pass.cc +++ b/src/objects/pass.cc @@ -337,7 +337,8 @@ auto RenderPass::draw(Engine *engine) -> void if (this->combine) Render::blend_func(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); else Render::blend_func(GL_ONE, GL_ZERO); - Render::color_mask(1.f, 1.f, 1.f, this->combine ? 0.f : 1.f); + //Render::color_mask(1.f, 1.f, 1.f, this->combine ? 0.f : 1.f); + Render::color_mask(1.f, 1.f, 1.f, 1.f); engine->view.default_viewport(adjusted_target->buffer->width, adjusted_target->buffer->height); diff --git a/subprojects/libalabaster.wrap b/subprojects/libalabaster.wrap index 038be37..243dff8 100644 --- a/subprojects/libalabaster.wrap +++ b/subprojects/libalabaster.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/libalabaster -revision = f6a8686b2c209b0e25cd64a587d6e9fb55200ec4 +revision = ec99011aca3a9b92964c653d74d693e693ac052f depth = 1 diff --git a/subprojects/libnaunet.wrap b/subprojects/libnaunet.wrap index 14965e1..3f43502 100644 --- a/subprojects/libnaunet.wrap +++ b/subprojects/libnaunet.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/libnaunet -revision = de6f6090f94b14ed98dac71956ff1bede48f1d8e +revision = 6993b9814769668fb03b4d282734f20f63b16f9c depth = 1 diff --git a/subprojects/stela.wrap b/subprojects/stela.wrap index c6daa98..4d0add3 100644 --- a/subprojects/stela.wrap +++ b/subprojects/stela.wrap @@ -1,4 +1,4 @@ [wrap-git] url = https://git.akon.city/stela -revision = a3fb42db50542a7e1fca8662d08d3764006c9887 +revision = a2e04b98512e9db93d5457ecc52ac385b9a9e0aa depth = 1 diff --git a/taro/config.h b/taro/config.h index 16fad79..cca7807 100644 --- a/taro/config.h +++ b/taro/config.h @@ -57,7 +57,7 @@ static void parse_config_json(struct config *conf, char *envhome, json_t *root) json_t *assets = json_object_get(directories, "assets"); if (!assets || !json_is_string(assets) || al_strlen(json_string_value(assets)) == 0) { - error("asset directory not set or invalid"); + log_error("asset directory not set or invalid"); conf->valid = false; goto out; } @@ -71,13 +71,13 @@ static void parse_config_json(struct config *conf, char *envhome, json_t *root) json_t *value; json_array_foreach(wallpapers, index, value) { if (!json_is_string(value) || al_strlen(json_string_value(value)) == 0) { - error("invalid wallpaper directory (index: %zu)", index); + log_error("invalid wallpaper directory (index: %zu)", index); continue; } str path; maybe_replace_home_in_path(&path, envhome, json_string_value(value)); if (!nn_dir_exists(&path)) { - warn("directory does not exist %.*s", al_str_x(&path)); + log_warn("directory does not exist %.*s", al_str_x(&path)); al_str_free(&path); continue; } @@ -85,7 +85,7 @@ static void parse_config_json(struct config *conf, char *envhome, json_t *root) } if (conf->wallpaper_dirs.count == 0) { - error("no valid wallpaper directories"); + log_error("no valid wallpaper directories"); conf->valid = false; goto out; } diff --git a/taro/daemon.c b/taro/daemon.c index 92e6388..a26de8b 100644 --- a/taro/daemon.c +++ b/taro/daemon.c @@ -83,7 +83,7 @@ static s32 parse_and_set_props(str *selection, str *wallpaper_id, bool *is_packa static bool send_signal_to_pid(pid_t pid, s32 signal) { if (kill(pid, signal) != 0) { - error("kill(%d) failed (%s)", pid, nn_strerror(errno)); + log_error("kill(%d) failed (%s)", pid, nn_strerror(errno)); return false; } return true; @@ -103,11 +103,11 @@ static pid_t exec_or_exit(char *args[]) { pid_t pid = fork(); if (pid == -1) { - error("fatal: failed to fork process, exiting..."); + log_error("fatal: failed to fork process, exiting..."); exit(EXIT_FAILURE); } else if (pid == 0) { if (execvp(args[0], args) == -1) { - error("fatal: failed to run '%s', exiting...", args[0]); + log_error("fatal: failed to run '%s', exiting...", args[0]); // This should return the pid of init if the parent process has already exited. pid_t ppid = getppid(); if (ppid != 1) send_signal_to_pid(ppid, SIGINT); @@ -132,21 +132,21 @@ static void maybe_kill_wallpaper(struct monitor *monitor) static bool search_wallpaper_dirs(struct daemon *dmon, str *id, str *path) { bool found = false; - debug("searching for wallpaper of id %.*s", al_str_x(id)); + log_debug("searching for wallpaper of id %.*s", al_str_x(id)); str *dir; al_array_foreach_ptr(dmon->conf.wallpaper_dirs, i, dir) { - debug("checking dir %.*s", al_str_x(dir)); + log_debug("checking dir %.*s", al_str_x(dir)); al_str_clone(path, dir); if (al_str_at(path, 1) != '/') al_str_cat(path, &al_str_c("/")); al_str_cat(path, id); if (nn_dir_exists(path)) { - debug("found wallpaper"); + log_debug("found wallpaper"); found = true; break; } al_str_free(path); } - if (!found) error("failed to find wallpaper of id %.*s", al_str_x(id)); + if (!found) log_error("failed to find wallpaper of id %.*s", al_str_x(id)); al_str_free(id); return found; } @@ -156,7 +156,7 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) maybe_kill_wallpaper(monitor); if (!dmon->conf.valid) { - error("config invalid, not setting wallpaper on %s", monitor->os->name); + log_error("config invalid, not setting wallpaper on %s", monitor->os->name); return false; } @@ -168,7 +168,7 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) } if (selection.length == 0) { - error("config for %s is empty", monitor->os->name); + log_error("config for %s is empty", monitor->os->name); al_str_free(&selection); return false; } @@ -179,7 +179,7 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) al_str_free(&selection); if (ret != 0) { if (ret == -1) { - error("failed to set properties for wallpaper on %s", monitor->os->name); + log_error("failed to set properties for wallpaper on %s", monitor->os->name); } al_str_free(&wallpaper_id); return false; @@ -195,14 +195,14 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) if (!nn_file_exists(&wallpaper_path)) { al_str_insert(&wallpaper_path, wallpaper_path.length - 9, &al_str_c("gif")); if (!nn_file_exists(&wallpaper_path)) { - error("wallpaper at %.*s has no package file", al_str_x(&wallpaper_path)); + log_error("wallpaper at %.*s has no package file", al_str_x(&wallpaper_path)); al_str_free(&wallpaper_path); return false; } } } - info("setting wallpaper %.*s on %s", al_str_x(&wallpaper_path), monitor->os->name); + log_info("setting wallpaper %.*s on %s", al_str_x(&wallpaper_path), monitor->os->name); char width[8], height[8]; al_snprintf(width, sizeof(width), "%d", monitor->os->width / monitor->os->scale); @@ -212,10 +212,10 @@ static bool run_wallpaper(struct daemon *dmon, struct monitor *monitor) char *c_str1 = al_str_to_c_str(&dmon->conf.asset_dir); if (is_package) { monitor->pid = exec_or_exit((char *[]){ - "mauri", "-p", c_str0, "-a", c_str1, "-m", monitor->os->name, "-w", width, "-h", height, NULL}); + "mauri", "-p", c_str0, "-a", c_str1, "-m", monitor->os->name, "-w", width, "-h", height, NULL }); } else { monitor->pid = exec_or_exit((char *[]){ - "mauri", "-d", c_str0, "-a", c_str1, "-m", monitor->os->name, "-w", width, "-h", height, NULL}); + "mauri", "-d", c_str0, "-a", c_str1, "-m", monitor->os->name, "-w", width, "-h", height, NULL }); } al_str_free(&wallpaper_path); al_free(c_str0); @@ -301,7 +301,7 @@ static void conf_fs_event_callback(void *userdata, struct inotify_event *event) (void)event; close_config(&dmon->conf); if (!open_config(&dmon->conf, false)) { - error("config became unavailable, exiting..."); + log_error("config became unavailable, exiting..."); exit(EXIT_FAILURE); } struct monitor *monitor; @@ -320,20 +320,20 @@ static void close_monitor(struct monitor *monitor) static void ipc_handle_subscribe_success(json_t *root) { if (json_boolean_value(root)) { - info("successfully subscribed to sway background covered events"); + log_info("successfully subscribed to sway background covered events"); } else { - info("failed to subscribe to sway background covered events"); + log_info("failed to subscribe to sway background covered events"); } } static void ipc_handle_response(struct daemon *dmon, u8 *buf, u32 size) { - debug("IN: %.*s", size, (char *)buf); + log_debug("IN: %.*s", size, (char *)buf); json_error_t error; json_t *root = json_loadb((char *)buf, size, 0, &error); if (!root) { - error("failed to parse sway-ipc json payload (%s)", error.text); + log_error("failed to parse sway-ipc json payload (%s)", error.text); goto done; } @@ -398,7 +398,7 @@ static void ipc_poll_callback(void *userdata, s32 revents) if (revents & NNWT_POLL_WRITE) { al_assert(!dmon->ipc_connected); if (!dmon->ipc_connected) { - info("connected to sway ipc socket"); + log_info("connected to sway ipc socket"); dmon->ipc_connected = true; } ssize_t ret = nn_socket_write(&dmon->ipc_socket, dmon->out.buf + dmon->out.index, dmon->out.size - dmon->out.index); @@ -542,7 +542,7 @@ s32 main(void) nn_poll_start(&dmon.ipc_poll, &dmon.loop); } else { dmon.ipc_errored = true; - warn("couldn't connect to sway ipc socket"); + log_warn("couldn't connect to sway ipc socket"); } nn_fs_event_init(&dmon.conf_event, &dmon.conf.config_path, NNWT_CLOSE_WRITE, conf_fs_event_callback, &dmon); @@ -76,7 +76,7 @@ static bool load_entry(struct entry *e) type = json_object_get(iter_obj, "type"); if (!type) { // Silently ignore for now. Is "Notes" a special case? see 1918273588. - //warn("improperly handled prop (%.*s)", al_str_x(&e->id)); + //log_warn("improperly handled prop (%.*s)", al_str_x(&e->id)); iter = json_object_iter_next(properties, iter); continue; } @@ -85,7 +85,7 @@ static bool load_entry(struct entry *e) if (al_str_eq(&type_str, &al_str_c("bool"))) { json_t *value = json_object_get(iter_obj, "value"); if (!value) { - warn("improperly handled bool (%.*s)", al_str_x(&e->id)); + log_warn("improperly handled bool (%.*s)", al_str_x(&e->id)); iter = json_object_iter_next(properties, iter); continue; } @@ -97,7 +97,7 @@ static bool load_entry(struct entry *e) json_t *min = json_object_get(iter_obj, "min"); json_t *max = json_object_get(iter_obj, "max"); if (!value || !min || !max) { - warn("improperly handled slider (%.*s)", al_str_x(&e->id)); + log_warn("improperly handled slider (%.*s)", al_str_x(&e->id)); iter = json_object_iter_next(properties, iter); continue; } @@ -115,7 +115,7 @@ static bool load_entry(struct entry *e) } p.type = PROP_TYPE_SLIDER; } else { - //warn("unhandled type. (%.*s)", al_str_x(type_str)); + //log_warn("unhandled type. (%.*s)", al_str_x(type_str)); } al_array_push(e->props, p); diff --git a/taro/file_ext.c b/taro/file_ext.c index 78fdba8..b419981 100644 --- a/taro/file_ext.c +++ b/taro/file_ext.c @@ -34,7 +34,7 @@ json_t *nn_file_open_as_json(str *path) json_error_t error; json_t *root = json_loadb(s.data, s.length, 0, &error); if (!root) { - error("json_loadb(%.*s, %u) failed (%s)", al_str_x(path), s.length, error.text); + log_error("json_loadb(%.*s, %u) failed (%s)", al_str_x(path), s.length, error.text); } al_str_free(&s); return root; @@ -100,6 +100,7 @@ struct info_prop { struct info { struct ncplane *ip; struct entry *e; + f32 flash; bool blitted; struct scrolling_text text; u32 max_props; @@ -169,6 +170,9 @@ static void select_monitor(struct ui *u) al_str_cat(&u->m.selection_path, &al_str_cr(monitor)); al_str_cat(&u->m.selection_path, &al_str_c("/selection")); u->g.set_index = get_entry_from_config(u); + if (u->g.set_index >= 0) { + u->g.selected_index = u->g.set_index; + } } static void write_selected_entry_to_config(struct ui *u) @@ -242,7 +246,7 @@ static bool init_monitors(struct ui *u, struct monitors *m) bool ret = nn_file_open_and_read_wholly(&monitors_path, &monitors, false); al_str_free(&monitors_path); if (!ret) { - error("failed to open monitor list, has `tarod` run?"); + log_error("failed to open monitor list, has `tarod` run?"); return false; } str monitor_dir; @@ -291,7 +295,7 @@ static bool init_ui(struct ui *u) if (!init_image_pool(&u->pool)) return false; if (!init_info(&u->n)) return false; if (!(u->nc = notcurses_init(NULL, stdin))) { - error("failed to initialize notcurses"); + log_error("failed to initialize notcurses"); return false; } al_set_print(void_print_callback, NULL); @@ -777,6 +781,7 @@ void draw_info(struct ui *u, struct info *n, bool update_text) ncplane_erase(u->ip); + struct ncvisual_options vopts = { 0 }; vopts.scaling = PIXEL_BLIT ? NCSCALE_SCALE_HIRES : NCSCALE_STRETCH; vopts.blitter = PIXEL_BLIT ? NCBLIT_PIXEL : NCBLIT_2x1; @@ -811,9 +816,17 @@ void draw_info(struct ui *u, struct info *n, bool update_text) } ip = &al_array_at(n->props, index); if (u->selected_menu == MENU_INFO && index == (u32)n->selected_prop) { - ncplane_set_fg_palindex(u->ip, 8); + if (n->flash > 0.f) { + ncplane_set_fg_palindex(u->ip, 0); + ncplane_set_bg_palindex(u->ip, 7); + n->flash -= MAX(TIMER_UPDATE_BASE * (u->delay / 1000000.f), 0.001f); + } else { + ncplane_set_fg_palindex(u->ip, 8); + ncplane_set_bg_default(u->ip); + } } else { ncplane_set_fg_default(u->ip); + ncplane_set_bg_default(u->ip); } draw_scrolling_text(u->ip, &ip->text, update_text); switch (ip->p->type) { @@ -898,21 +911,23 @@ static bool handle_input_monitors(struct ui *u, struct monitors *m, struct ncinp bool should_redraw_info = false; switch (input->id) { case NCKEY_LEFT: - case 'h': + case 'h': { if (m->selected_monitor - 1 < 0) { return false; } m->selected_monitor--; should_redraw_monitors = true; break; + } case NCKEY_RIGHT: - case 'l': + case 'l': { if ((u32)(m->selected_monitor + 1) >= m->monitors.count) { return false; } m->selected_monitor++; should_redraw_monitors = true; break; + } case NCKEY_RETURN: case NCKEY_SPACE: { select_monitor(u); @@ -942,21 +957,23 @@ static bool handle_input_info(struct ui *u, struct info *n, struct ncinput *inpu bool should_redraw_info = false; switch (input->id) { case NCKEY_UP: - case 'k': + case 'k': { if (n->selected_prop - 1 < 0) { return false; } n->selected_prop--; should_redraw_info = true; break; + } case NCKEY_DOWN: - case 'j': + case 'j': { if ((u32)(n->selected_prop + 1) >= n->props.count) { return false; } n->selected_prop++; should_redraw_info = true; break; + } case NCKEY_RETURN: case NCKEY_SPACE: { if (!n->props.count) return false; @@ -971,7 +988,7 @@ static bool handle_input_info(struct ui *u, struct info *n, struct ncinput *inpu case NCKEY_LEFT: case 'h': case NCKEY_RIGHT: - case 'l': + case 'l': { if (!n->props.count) return false; struct prop *p = &al_array_at(n->e->props, n->selected_prop); if (p->type == PROP_TYPE_SLIDER) { @@ -1000,6 +1017,7 @@ static bool handle_input_info(struct ui *u, struct info *n, struct ncinput *inpu } break; } + } if (should_redraw_info) draw_info(u, n, false); return should_redraw_info; } @@ -1039,7 +1057,7 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu bool should_redraw_info = false; switch (input->id) { case NCKEY_LEFT: - case 'h': + case 'h': { if (g->selected_index - 1 < 0) { return false; } @@ -1051,8 +1069,9 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu should_redraw_info = true; should_redraw_grid = true; break; + } case NCKEY_RIGHT: - case 'l': + case 'l': { if (g->selected_index + 1 >= (s32)u->db.entries.count) { return false; } @@ -1064,8 +1083,9 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu should_redraw_info = true; should_redraw_grid = true; break; + } case NCKEY_UP: - case 'k': + case 'k': { if (g->selected_index - g->tiles_x < g->min_index) { return false; } @@ -1073,8 +1093,9 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu should_redraw_info = true; should_redraw_grid = true; break; + } case NCKEY_DOWN: - case 'j': + case 'j': { if (g->selected_index + g->tiles_x > g->max_index) { return false; } @@ -1082,26 +1103,30 @@ static bool handle_input_grid(struct ui *u, struct grid *g, struct ncinput *inpu should_redraw_info = true; should_redraw_grid = true; break; - case 'f': + } + case 'f': { if (grid_next_page(u, &u->g, 0)) { should_update_grid = true; should_redraw_info = true; should_redraw_grid = true; } break; - case 'b': + } + case 'b': { if (grid_previous_page(&u->g, 0)) { should_update_grid = true; should_redraw_info = true; should_redraw_grid = true; } break; - case 'r': + } + case 'r': { g->set_index = -1; write_selected_entry_to_config(u); should_redraw_grid = true; should_redraw_info = true; break; + } case 's': { if (!u->db.entries.count) { return false; @@ -1156,6 +1181,7 @@ static void input_poll_callback(void *userdata, s32 revents) case MENU_GRID: if (u->n.props.count > 0) { u->selected_menu = MENU_INFO; + u->n.flash = FLASH_DURATION; } else { u->selected_menu = MENU_MONITORS; } @@ -1225,7 +1251,7 @@ s32 main(void) if (!nn_common_init()) return EXIT_FAILURE; if (!open_config(&u.conf, false)) { - error("failed to open config, run `tarod` at least once to generate needed config"); + log_error("failed to open config, run `tarod` at least once to generate needed config"); return EXIT_FAILURE; } @@ -1249,7 +1275,7 @@ s32 main(void) if (!layout_ui(&u)) { notcurses_stop(u.nc); - error("failed to layout ui, your terminal window is probably too small"); + log_error("failed to layout ui, your terminal window is probably too small"); goto out; } u.layed_out = true; |