Re: Patch 8.0.0873

2017-08-05 Fir de Conversatie Bram Moolenaar

Dominique wrote:

> > Patch 8.0.0873
> > Problem:In a terminal window cannot use CTRL-\ CTRL-N to start Visual
> > mode.
> > Solution:   After CTRL-\ CTRL-N enter Terminal-Normal mode for one command.
> > Files:  src/main.c, src/terminal.c, src/proto/terminal.pro
> 
> This patch is causing a compilation error when
> I configure vim with:
> 
> $ ./configure --with-features=huge --enable-gui=none
> --enable-terminal --enable-python3interp
> $ make
> ...
> normal.c: In function 'nv_mousescroll':
> normal.c:4642:6: error: too few arguments to function 'term_use_loop'
>   if (term_use_loop())
>   ^
> In file included from proto.h:167:0,
>  from vim.h:2119,
>  from normal.c:15:
> proto/terminal.pro:9:5: note: declared here
>  int term_use_loop(int once);
>  ^
> 
> I suppose that it should be fixed like this:
> 
> diff --git a/src/normal.c b/src/normal.c
> index 25ab2d3..88f604d 100644
> --- a/src/normal.c
> +++ b/src/normal.c
> @@ -4639,7 +4639,7 @@ nv_mousescroll(cmdarg_T *cap)
>  if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
>  {
>  # ifdef FEAT_TERMINAL
> -   if (term_use_loop())
> +   if (term_use_loop(FALSE))
> send_keys_to_term(curbuf->b_term, cap->cmdchar, TRUE);
> else
>  # endif

Yes, sorry, I forgot to include that change in the patch.

-- 
Michael: There is no such thing as a dump question.
Bernard: Sure there is.  For example "what is a core dump?"

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Patch 8.0.0873

2017-08-05 Fir de Conversatie Dominique Pellé
Bram Moolenaar <b...@moolenaar.net> wrote:

> Patch 8.0.0873
> Problem:In a terminal window cannot use CTRL-\ CTRL-N to start Visual
> mode.
> Solution:   After CTRL-\ CTRL-N enter Terminal-Normal mode for one command.
> Files:  src/main.c, src/terminal.c, src/proto/terminal.pro

This patch is causing a compilation error when
I configure vim with:

$ ./configure --with-features=huge --enable-gui=none
--enable-terminal --enable-python3interp
$ make
...
normal.c: In function 'nv_mousescroll':
normal.c:4642:6: error: too few arguments to function 'term_use_loop'
  if (term_use_loop())
  ^
In file included from proto.h:167:0,
 from vim.h:2119,
 from normal.c:15:
proto/terminal.pro:9:5: note: declared here
 int term_use_loop(int once);
 ^

I suppose that it should be fixed like this:

diff --git a/src/normal.c b/src/normal.c
index 25ab2d3..88f604d 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -4639,7 +4639,7 @@ nv_mousescroll(cmdarg_T *cap)
 if (cap->arg == MSCR_UP || cap->arg == MSCR_DOWN)
 {
 # ifdef FEAT_TERMINAL
-   if (term_use_loop())
+   if (term_use_loop(FALSE))
send_keys_to_term(curbuf->b_term, cap->cmdchar, TRUE);
else
 # endif

Dominique

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Patch 8.0.0873

2017-08-05 Fir de Conversatie Bram Moolenaar

Patch 8.0.0873
Problem:In a terminal window cannot use CTRL-\ CTRL-N to start Visual
mode.
Solution:   After CTRL-\ CTRL-N enter Terminal-Normal mode for one command.
Files:  src/main.c, src/terminal.c, src/proto/terminal.pro


*** ../vim-8.0.0872/src/main.c  2017-07-30 16:51:35.622144012 +0200
--- src/main.c  2017-08-05 19:44:58.247829235 +0200
***
*** 1356,1362 
else
{
  #ifdef FEAT_TERMINAL
!   if (term_use_loop() && oa.op_type == OP_NOP && oa.regname == NUL)
{
/* If terminal_loop() returns OK we got a key that is handled
 * in Normal model.  With FAIL the terminal was closed and the
--- 1356,1364 
else
{
  #ifdef FEAT_TERMINAL
!   if (term_use_loop(TRUE)
!   && oa.op_type == OP_NOP && oa.regname == NUL
!   && !VIsual_active)
{
/* If terminal_loop() returns OK we got a key that is handled
 * in Normal model.  With FAIL the terminal was closed and the
*** ../vim-8.0.0872/src/terminal.c  2017-08-05 19:34:43.344410036 +0200
--- src/terminal.c  2017-08-05 20:12:44.503603800 +0200
***
*** 115,121 
  int   tl_tty_fd;
  char_u*tl_tty_name;
  
! int   tl_terminal_mode;
  int   tl_channel_closed;
  
  #ifdef WIN3264
--- 115,121 
  int   tl_tty_fd;
  char_u*tl_tty_name;
  
! int   tl_terminal_mode; /* 0, TMODE_ONCE or TMODE_LOOP */
  int   tl_channel_closed;
  
  #ifdef WIN3264
***
*** 144,149 
--- 144,152 
  int   tl_cursor_visible;
  };
  
+ #define TMODE_ONCE 1  /* CTRL-\ CTRL-N used */
+ #define TMODE_LOOP 2  /* CTRL-W N used */
+ 
  /*
   * List of all active terminals.
   */
***
*** 459,465 
  static void
  update_cursor(term_T *term, int redraw)
  {
! if (term->tl_terminal_mode)
return;
  setcursor();
  if (redraw && term->tl_buffer == curbuf)
--- 462,468 
  static void
  update_cursor(term_T *term, int redraw)
  {
! if (term->tl_terminal_mode != 0)
return;
  setcursor();
  if (redraw && term->tl_buffer == curbuf)
***
*** 492,498 
  ch_log(channel, "writing %d bytes to terminal", (int)len);
  term_write_job_output(term, msg, len);
  
! if (!term->tl_terminal_mode)
  {
/* TODO: only update once in a while. */
update_screen(0);
--- 495,501 
  ch_log(channel, "writing %d bytes to terminal", (int)len);
  term_write_job_output(term, msg, len);
  
! if (term->tl_terminal_mode == 0)
  {
/* TODO: only update once in a while. */
update_screen(0);
***
*** 805,813 
  }
  
  static void
! set_terminal_mode(term_T *term, int on)
  {
! term->tl_terminal_mode = on;
  vim_free(term->tl_status_text);
  term->tl_status_text = NULL;
  if (term->tl_buffer == curbuf)
--- 808,816 
  }
  
  static void
! set_terminal_mode(term_T *term, int mode)
  {
! term->tl_terminal_mode = mode;
  vim_free(term->tl_status_text);
  term->tl_status_text = NULL;
  if (term->tl_buffer == curbuf)
***
*** 823,844 
  {
  move_terminal_to_buffer(term);
  term_free_vterm(term);
! set_terminal_mode(term, FALSE);
  }
  
  /*
!  * Switch from sending keys to the job to Terminal-Normal mode.
   * Suspends updating the terminal window.
   */
  static void
! term_enter_terminal_mode()
  {
  term_T *term = curbuf->b_term;
  
  /* Append the current terminal contents to the buffer. */
  move_terminal_to_buffer(term);
  
! set_terminal_mode(term, TRUE);
  }
  
  /*
--- 826,860 
  {
  move_terminal_to_buffer(term);
  term_free_vterm(term);
! set_terminal_mode(term, 0);
  }
  
  /*
!  * Switch from Terminal-Job mode to Terminal-Normal mode.
   * Suspends updating the terminal window.
   */
  static void
! term_enter_terminal_mode(int mode)
  {
  term_T *term = curbuf->b_term;
  
  /* Append the current terminal contents to the buffer. */
  move_terminal_to_buffer(term);
  
! set_terminal_mode(term, mode);
! 
! if (mode == TMODE_ONCE)
! {
!   /* Move the window cursor to the position of the cursor in the
!* terminal. */
!   curwin->w_cursor.lnum = term->tl_scrollback_scrolled
!+ term->tl_cursor_pos.row + 1;
!   check_cursor();
!   coladvance(term->tl_cursor_pos.col);
! 
!   /* Display the same lines as in the terminal. */
!   curwin->w_topline = term->tl_scrollback_scrolled + 1;
! }
  }
  
  /*
***
*** 850,860 
  {
  term_T *te