One can now display only a part of each line to the user.
[selector.git] / selector.cc
index 0f47dfa..27225b9 100644 (file)
@@ -70,10 +70,10 @@ void inject_into_tty_buffer(char *string) {
   memset(&newtio, 0, sizeof(newtio));
   // Set input mode (non-canonical, *no echo*,...)
   tcsetattr(STDIN_FILENO, TCSANOW, &newtio);
-  char control_q = '\021';
+  const char control_q = '\021';
   // Put the selected string in the tty input buffer
-  for(char *k = string; *k; k++) {
-    if(add_control_qs) {
+  for(const char *k = string; *k; k++) {
+    if(add_control_qs && !(*k >= ' ' && *k <= '~')) {
       // Add ^Q to quote control characters
       ioctl(STDIN_FILENO, TIOCSTI, &control_q);
     }