commit a36bb43a3e7eb5156105479fe02f05639d5f1d89 from: Omar Polo date: Mon Jan 15 11:32:57 2024 UTC add the up, root and home commands These navigates respectively one level up in the path hierarchy, to the root directory and to the "home". The home is considered to be the first path component in the form of ~username. `home' is yet to be implemented. commit - 34f8174412bdd6f2e1f226a2b7bd00101c574ef8 commit + a36bb43a3e7eb5156105479fe02f05639d5f1d89 blob - b1c1869a631091efc16c273c6ad6e09c2b747f10 blob + 2b3921dcb7e0a0d518aea6e5ce49d2fbf30418e2 --- cmd.c +++ cmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Omar Polo + * Copyright (c) 2021, 2024 Omar Polo * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1063,4 +1063,24 @@ cmd_write_buffer(struct buffer *buffer) strlcat(path, f, sizeof(path)); ui_read("Write file", write_buffer, current_tab, path); +} + +void +cmd_home(struct buffer *buffer) +{ + message("Not implemented yet!"); +} + +void +cmd_root(struct buffer *buffer) +{ + load_url_in_tab(current_tab, "/", current_tab->hist_cur->h, + LU_MODE_NOCACHE); } + +void +cmd_up(struct buffer *buffer) +{ + load_url_in_tab(current_tab, "..", current_tab->hist_cur->h, + LU_MODE_NOCACHE); +} blob - 12f73a5299bb55bacec7fc2f7e9a085802ec7e7d blob + 2a142a5c132e43c57a9ef19b4eb45babcf9b24a6 --- defaults.c +++ defaults.c @@ -392,6 +392,9 @@ load_default_keys(void) global_set_key("g g", cmd_beginning_of_buffer); global_set_key("G", cmd_end_of_buffer); + global_set_key("g u", cmd_up); + global_set_key("g r", cmd_root); + global_set_key("g h", cmd_home); global_set_key("g D", cmd_tab_close); global_set_key("g N", cmd_tab_new); global_set_key("g t", cmd_tab_next); blob - 90b75c2faff223437b76a464dd98165e9dfaf05c blob + 9c1c5b40b82b072c84b713e30fa10a65b0807987 --- include/cmd.h +++ include/cmd.h @@ -22,6 +22,7 @@ CMD(cmd_end_of_buffer, "Move the point to the end of CMD(cmd_execute_extended_command, "Execute an internal command."); CMD(cmd_forward_char, "Move point one character forward."); CMD(cmd_forward_paragraph, "Move point one paragraph forward."); +CMD(cmd_home, "Go to the home directory."); CMD(cmd_inc_fill_column, "Increment fill-column by two"); CMD(cmd_insert_current_candidate, "Copy the current selection text as minibuffer input."); CMD(cmd_kill_telescope, "Quit Telescope."); @@ -60,6 +61,7 @@ CMD(cmd_push_button_new_tab, "Follow link at point in CMD(cmd_redraw, "Redraw the screen."); CMD(cmd_reload_page, "Reload the current page."); CMD(cmd_reply_last_input, "Reply last input request."); +CMD(cmd_root, "Go to the root directory."); CMD(cmd_scroll_down, "Scroll down by one visual page"); CMD(cmd_scroll_line_down, "Scroll down by one line"); CMD(cmd_scroll_line_up, "Scroll up by one line."); @@ -79,4 +81,5 @@ CMD(cmd_toc, "Jump to a heading using the minibuffer CMD(cmd_toggle_downloads, "Toggle the downloads side window."); CMD(cmd_toggle_help, "Toggle side window with help."); CMD(cmd_toggle_pre_wrap, "Toggle the wrapping of preformatted blocks."); +CMD(cmd_up, "Go up one level."); CMD(cmd_write_buffer, "Save the current page to the disk."); blob - 14643b4a19ce91c201e4f68d8c3bfacbe99f2c82 blob + a662565490fa4ba9e2a8c21a02f7386513972e08 --- telescope.1 +++ telescope.1 @@ -594,6 +594,12 @@ scroll-line-down beginning-of-buffer .It G end-of-buffer +.It g u +up +.It g r +root +.It g h +home .It g D tab-close .It g N @@ -823,6 +829,12 @@ Clear the echo area. Decrement fill-column by two. .It Ic execute-extended-command Execute an internal command. +.It Ic home +Go to the home directory. +The home directory is assumed to be the first path component in the +.Sy ~username +form. +If not found, loads the root directory. .It Ic kill-telescope Quit .Nm . @@ -860,6 +872,8 @@ display. Reload the current page. .It Ic reply-last-input Reply the last input request. +.It Ic root +Go to the root directory. .It Ic scroll-down Scroll down by one visual page. .It Ic scroll-line-down @@ -881,6 +895,8 @@ Toggle side window with help about available keys and interactive command. .It Ic toggle-pre-wrap Toggle the wrapping of preformatted blocks. +.It Ic up +Go up one level in the path hierarchy. .It Ic write-buffer Save the current buffer to the disk. .El