Fixed paste bug. github#11
This commit is contained in:
		
							parent
							
								
									24112ed67b
								
							
						
					
					
						commit
						eb7ebdfa01
					
				
					 1 changed files with 14 additions and 9 deletions
				
			
		
							
								
								
									
										23
									
								
								crussh.py
									
										
									
									
									
								
							
							
						
						
									
										23
									
								
								crussh.py
									
										
									
									
									
								
							| 
						 | 
					@ -132,6 +132,7 @@ class CruSSH:
 | 
				
			||||||
    ScrollWin = gtk.ScrolledWindow()
 | 
					    ScrollWin = gtk.ScrolledWindow()
 | 
				
			||||||
    LayoutTable = gtk.Table()
 | 
					    LayoutTable = gtk.Table()
 | 
				
			||||||
    EntryBox = gtk.Entry()
 | 
					    EntryBox = gtk.Entry()
 | 
				
			||||||
 | 
					    Clipboard = gtk.Clipboard()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ### Methods ###
 | 
					    ### Methods ###
 | 
				
			||||||
    def reflowTable(self, cols=1, rows=1):
 | 
					    def reflowTable(self, cols=1, rows=1):
 | 
				
			||||||
| 
						 | 
					@ -251,17 +252,21 @@ class CruSSH:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # forward key events to all terminals
 | 
					        # forward key events to all terminals
 | 
				
			||||||
        def feed_input(widget, event):
 | 
					        def feed_input(widget, event):
 | 
				
			||||||
            if event.type in [gtk.gdk.KEY_PRESS, gtk.gdk.KEY_RELEASE]:
 | 
					            self.EntryBox.props.buffer.delete_text(0, -1)
 | 
				
			||||||
                # erase buffer on every entry, so that passwords aren't revealed
 | 
					            # propagate to every terminal
 | 
				
			||||||
                self.EntryBox.props.buffer.delete_text(0, -1)
 | 
					            for host in self.Terminals:
 | 
				
			||||||
                # propagate to every terminal
 | 
					                t_event = event.copy()
 | 
				
			||||||
                for host in self.Terminals:
 | 
					                self.Terminals[host].event(t_event)
 | 
				
			||||||
                    t_event = event.copy()
 | 
					            # this stops regular handler from firing, switching focus.
 | 
				
			||||||
                    self.Terminals[host].event(t_event)
 | 
					            return True
 | 
				
			||||||
                # this stops regular handler from firing, switching focus.
 | 
					        def feed_paste(widget):
 | 
				
			||||||
                return True
 | 
					            for host in self.Terminals:
 | 
				
			||||||
 | 
					                self.Terminals[host].feed_child(self.Clipboard.wait_for_text())
 | 
				
			||||||
 | 
					            self.EntryBox.props.buffer.delete_text(0, -1)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.EntryBox.connect("key_press_event", feed_input)
 | 
					        self.EntryBox.connect("key_press_event", feed_input)
 | 
				
			||||||
        self.EntryBox.connect("key_release_event", feed_input)
 | 
					        self.EntryBox.connect("key_release_event", feed_input)
 | 
				
			||||||
 | 
					        self.EntryBox.connect("paste_clipboard", feed_paste)
 | 
				
			||||||
        MainVBox.pack_start(self.EntryBox, False, False)
 | 
					        MainVBox.pack_start(self.EntryBox, False, False)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # reflow layout on size change.
 | 
					        # reflow layout on size change.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue