Advertisement
talvo

Potato: Return on empty input inserts blank output line

Jul 27th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 1.35 KB | None | 0 0
  1. proc ::potato::send_mushage {window saveonly} {
  2.     variable inputSwap;
  3.     variable conn;
  4.     variable world;
  5.  
  6.     set c [up]
  7.  
  8.     if { $window eq "" } {
  9.         set window [connInfo $c input3]
  10.     }
  11.  
  12.  
  13.     if { [$window count -chars 1.0 end-1c] == 0 && $conn($c,connected) == 0 } {
  14.         reconnect [up]
  15.         return;
  16.     }
  17.  
  18.     set w $conn($c,world)
  19.  
  20.     # Figure out the auto-prefix, if any
  21.     set windowName [textWidgetName [activeTextWidget] $c]
  22.     if { $windowName eq "" } {
  23.         set windows [list _all]
  24.     } else {
  25.         set windows [list $windowName _all]
  26.     }
  27.     if { $w == 0 } {
  28.         set worlds [list 0]
  29.     } else {
  30.         set worlds [list $w 0]
  31.     }
  32.     foreach w $worlds {
  33.         if { [info exists prefix] } {
  34.             break;
  35.         }
  36.         foreach x $windows {
  37.             set pos [lsearch -exact -index 0 $world($w,prefixes) $x]
  38.             if { $pos != -1 } {
  39.                 set entry [lindex $world($w,prefixes) $pos]
  40.                 if { [lindex $entry 2] == 1 } {
  41.                     set prefix [lindex $entry 1]
  42.                     break;
  43.                 }
  44.             }
  45.         }
  46.     }
  47.     if { ![info exists prefix] } {
  48.         set prefix ""
  49.     }
  50.  
  51.     set txt [$window get 1.0 end-1char]
  52.     $window edit separator
  53.     $window replace 1.0 end ""
  54.    
  55.     if { $txt eq "" } {
  56.         get_mushageProcess $c ""
  57.         return;
  58.     }
  59.  
  60.     set inputSwap($window,count) -1
  61.     set inputSwap($window,backup) ""
  62.  
  63.     addToInputHistory $c $txt
  64.  
  65.     if { $saveonly } {
  66.         return;
  67.     }
  68.  
  69.     send_to $c $txt $prefix
  70.  
  71.     return;
  72.  
  73. };# ::potato::send_mushage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement