diff options
author | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
---|---|---|
committer | Josh Rahm <joshuarahm@gmail.com> | 2025-02-05 23:09:29 +0000 |
commit | d5f194ce780c95821a855aca3c19426576d28ae0 (patch) | |
tree | d45f461b19f9118ad2bb1f440a7a08973ad18832 /src/nvim/ex_docmd.c | |
parent | c5d770d311841ea5230426cc4c868e8db27300a8 (diff) | |
parent | 44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff) | |
download | rneovim-rahm.tar.gz rneovim-rahm.tar.bz2 rneovim-rahm.zip |
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 63 |
1 files changed, 49 insertions, 14 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f5ecedf827..ceb17a995d 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -51,7 +51,6 @@ #include "nvim/getchar.h" #include "nvim/gettext_defs.h" #include "nvim/globals.h" -#include "nvim/highlight.h" #include "nvim/highlight_defs.h" #include "nvim/highlight_group.h" #include "nvim/input.h" @@ -980,12 +979,10 @@ void handle_did_throw(void) force_abort = true; } - msg_ext_set_kind("emsg"); // kind=emsg for :throw, exceptions. #9993 - if (messages != NULL) { do { msglist_T *next = messages->next; - emsg_multiline(messages->msg, messages->multiline); + emsg_multiline(messages->msg, "emsg", HLF_E, messages->multiline); xfree(messages->msg); xfree(messages->sfile); xfree(messages); @@ -2204,7 +2201,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter errormsg = _("E493: Backwards range given"); goto doend; } - if (ask_yesno(_("Backwards range given, OK to swap"), false) != 'y') { + if (ask_yesno(_("Backwards range given, OK to swap")) != 'y') { goto doend; } } @@ -4504,6 +4501,12 @@ static void ex_bunload(exarg_T *eap) /// :[N]sbuffer [N] to buffer N static void ex_buffer(exarg_T *eap) { + do_exbuffer(eap); +} + +/// ":buffer" command and alike. +static void do_exbuffer(exarg_T *eap) +{ if (*eap->arg) { eap->errmsg = ex_errmsg(e_trailing_arg, eap->arg); } else { @@ -6103,12 +6106,20 @@ static void ex_sleep(exarg_T *eap) default: semsg(_(e_invarg2), eap->arg); return; } - do_sleep(len); + + // Hide the cursor if invoked with ! + do_sleep(len, eap->forceit); } /// Sleep for "msec" milliseconds, but return early on CTRL-C. -void do_sleep(int64_t msec) +/// +/// @param hide_cursor hide the cursor if true +void do_sleep(int64_t msec, bool hide_cursor) { + if (hide_cursor) { + ui_busy_start(); + } + ui_flush(); // flush before waiting LOOP_PROCESS_EVENTS_UNTIL(&main_loop, main_loop.events, msec, got_int); @@ -6117,6 +6128,10 @@ void do_sleep(int64_t msec) if (got_int) { vpeekc(); } + + if (hide_cursor) { + ui_busy_stop(); + } } /// ":winsize" command (obsolete). @@ -6992,14 +7007,35 @@ static void ex_ptag(exarg_T *eap) static void ex_pedit(exarg_T *eap) { win_T *curwin_save = curwin; + prepare_preview_window(); + // Edit the file. + do_exedit(eap, NULL); + + back_to_current_window(curwin_save); +} + +/// ":pbuffer" +static void ex_pbuffer(exarg_T *eap) +{ + win_T *curwin_save = curwin; + prepare_preview_window(); + + // Go to the buffer. + do_exbuffer(eap); + + back_to_current_window(curwin_save); +} + +static void prepare_preview_window(void) +{ // Open the preview window or popup and make it the current window. g_do_tagpreview = (int)p_pvh; prepare_tagpreview(true); +} - // Edit the file. - do_exedit(eap, NULL); - +static void back_to_current_window(win_T *curwin_save) +{ if (curwin != curwin_save && win_valid(curwin_save)) { // Return cursor to where we were validate_cursor(curwin); @@ -7364,8 +7400,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum *errormsg = _(e_usingsid); return NULL; } - snprintf(strbuf, sizeof(strbuf), "<SNR>%" PRIdSCID "_", - current_sctx.sc_sid); + snprintf(strbuf, sizeof(strbuf), "<SNR>%" PRIdSCID "_", current_sctx.sc_sid); result = strbuf; break; @@ -7738,7 +7773,7 @@ static void ex_terminal(exarg_T *eap) if (*eap->arg != NUL) { // Run {cmd} in 'shell'. char *name = vim_strsave_escaped(eap->arg, "\"\\"); snprintf(ex_cmd + len, sizeof(ex_cmd) - len, - " | call termopen(\"%s\")", name); + " | call jobstart(\"%s\",{'term':v:true})", name); xfree(name); } else { // No {cmd}: run the job with tokenized 'shell'. if (*p_sh == NUL) { @@ -7761,7 +7796,7 @@ static void ex_terminal(exarg_T *eap) shell_free_argv(argv); snprintf(ex_cmd + len, sizeof(ex_cmd) - len, - " | call termopen([%s])", shell_argv + 1); + " | call jobstart([%s], {'term':v:true})", shell_argv + 1); } do_cmdline_cmd(ex_cmd); |