diff options
author | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-25 22:08:14 -0300 |
---|---|---|
committer | Thiago de Arruda <tpadilha84@gmail.com> | 2015-03-25 22:08:14 -0300 |
commit | a6e53a3797a93fe060f807fe2e4c6361854b6c97 (patch) | |
tree | b684785ba9c769491e6ebdac8e21495cf22dbdd3 /src/nvim/ops.c | |
parent | d2d99454e63c0e6649fddd52bbd9a10d27c2e347 (diff) | |
parent | 2aa2513b8e023a0d7bd2071299f0ea59a4d4ce25 (diff) | |
download | rneovim-a6e53a3797a93fe060f807fe2e4c6361854b6c97.tar.gz rneovim-a6e53a3797a93fe060f807fe2e4c6361854b6c97.tar.bz2 rneovim-a6e53a3797a93fe060f807fe2e4c6361854b6c97.zip |
Merge PR #2076 'Builtin terminal emulation'
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r-- | src/nvim/ops.c | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 7f2df8199c..2714798368 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -45,6 +45,7 @@ #include "nvim/screen.h" #include "nvim/search.h" #include "nvim/strings.h" +#include "nvim/terminal.h" #include "nvim/ui.h" #include "nvim/undo.h" #include "nvim/window.h" @@ -583,7 +584,7 @@ void op_reindent(oparg_T *oap, Indenter how) linenr_T start_lnum = curwin->w_cursor.lnum; /* Don't even try when 'modifiable' is off. */ - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return; } @@ -1329,7 +1330,7 @@ int op_delete(oparg_T *oap) if (oap->empty) return u_save_cursor(); - if (!curbuf->b_p_ma) { + if (!MODIFIABLE(curbuf)) { EMSG(_(e_modifiable)); return FAIL; } @@ -2643,11 +2644,13 @@ do_put ( return; } - /* Autocommands may be executed when saving lines for undo, which may make - * y_array invalid. Start undo now to avoid that. */ - if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { - ELOG(_("Failed to save undo information")); - return; + if (!curbuf->terminal) { + // Autocommands may be executed when saving lines for undo, which may make + // y_array invalid. Start undo now to avoid that. + if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { + ELOG(_("Failed to save undo information")); + return; + } } if (insert_string != NULL) { @@ -2692,6 +2695,20 @@ do_put ( y_array = y_current->y_array; } + if (curbuf->terminal) { + for (int i = 0; i < count; i++) { + // feed the lines to the terminal + for (int j = 0; j < y_size; j++) { + if (j) { + // terminate the previous line + terminal_send(curbuf->terminal, "\n", 1); + } + terminal_send(curbuf->terminal, (char *)y_array[j], STRLEN(y_array[j])); + } + } + return; + } + if (y_type == MLINE) { if (flags & PUT_LINE_SPLIT) { /* "p" or "P" in Visual mode: split the lines to put the text in |