mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	ex_echo: reuse code from message.c to show arg to user
This commit is contained in:
		 Alexandre Dubray
					Alexandre Dubray
				
			
				
					committed by
					
						 Björn Linse
						Björn Linse
					
				
			
			
				
	
			
			
			 Björn Linse
						Björn Linse
					
				
			
						parent
						
							7f2e43c637
						
					
				
				
					commit
					67bac681ea
				
			| @@ -19593,24 +19593,7 @@ void ex_echo(exarg_T *eap) | |||||||
|         msg_puts_attr(" ", echo_attr); |         msg_puts_attr(" ", echo_attr); | ||||||
|       } |       } | ||||||
|       char *tofree = encode_tv2echo(&rettv, NULL); |       char *tofree = encode_tv2echo(&rettv, NULL); | ||||||
|       const char *p = tofree; |       msg_echo_show(tofree, echo_attr); | ||||||
|       if (p != NULL) { |  | ||||||
|         for (; *p != NUL && !got_int; ++p) { |  | ||||||
|           if (*p == '\n' || *p == '\r' || *p == TAB) { |  | ||||||
|             if (*p != TAB && needclr) { |  | ||||||
|               /* remove any text still there from the command */ |  | ||||||
|               msg_clr_eos(); |  | ||||||
|               needclr = false; |  | ||||||
|             } |  | ||||||
|             msg_putchar_attr((uint8_t)(*p), echo_attr); |  | ||||||
|           } else { |  | ||||||
|             int i = (*mb_ptr2len)((const char_u *)p); |  | ||||||
|  |  | ||||||
|             (void)msg_outtrans_len_attr((char_u *)p, i, echo_attr); |  | ||||||
|             p += i - 1; |  | ||||||
|           } |  | ||||||
|         } |  | ||||||
|       } |  | ||||||
|       xfree(tofree); |       xfree(tofree); | ||||||
|     } |     } | ||||||
|     tv_clear(&rettv); |     tv_clear(&rettv); | ||||||
|   | |||||||
| @@ -173,23 +173,9 @@ bool msg_attr_skip(const char *s, const int attr, int *const call) | |||||||
|   return false; |   return false; | ||||||
| } | } | ||||||
|  |  | ||||||
|  | void msg_echo_show(const char *s, int attr) | ||||||
| bool msg_echo_attr_keep(const char *s, const int attr, const int keep) |  | ||||||
|   FUNC_ATTR_NONNULL_ALL |   FUNC_ATTR_NONNULL_ALL | ||||||
| { | { | ||||||
|   static int entered = 0; |  | ||||||
|  |  | ||||||
|   if (msg_attr_skip(s, attr, &entered)) { |  | ||||||
|     return true; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   msg_start(); |  | ||||||
|  |  | ||||||
|   char *const buf = (char *)msg_strtrunc((char_u *)s, false); |  | ||||||
|   if (buf != NULL) { |  | ||||||
|     s = buf; |  | ||||||
|   } |  | ||||||
|  |  | ||||||
|   const char *next_spec = s; |   const char *next_spec = s; | ||||||
|  |  | ||||||
|   while (next_spec != NULL) { |   while (next_spec != NULL) { | ||||||
| @@ -212,6 +198,25 @@ bool msg_echo_attr_keep(const char *s, const int attr, const int keep) | |||||||
|   if (*s != NUL) { |   if (*s != NUL) { | ||||||
|     msg_outtrans_attr((char_u *)s, attr); |     msg_outtrans_attr((char_u *)s, attr); | ||||||
|   } |   } | ||||||
|  | } | ||||||
|  |  | ||||||
|  | bool msg_echo_attr_keep(const char *s, const int attr, const int keep) | ||||||
|  |   FUNC_ATTR_NONNULL_ALL | ||||||
|  | { | ||||||
|  |   static int entered = 0; | ||||||
|  |  | ||||||
|  |   if (msg_attr_skip(s, attr, &entered)) { | ||||||
|  |     return true; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   msg_start(); | ||||||
|  |  | ||||||
|  |   char *const buf = (char *)msg_strtrunc((char_u *)s, false); | ||||||
|  |   if (buf != NULL) { | ||||||
|  |     s = buf; | ||||||
|  |   } | ||||||
|  |  | ||||||
|  |   msg_echo_show(s, attr); | ||||||
|  |  | ||||||
|   msg_clr_eos(); |   msg_clr_eos(); | ||||||
|   const bool retval = msg_end(); |   const bool retval = msg_end(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user