← Back to team overview

clicompanion-devs team mailing list archive

[Merge] lp:~dcaro/clicompanion/fix-614789 into lp:clicompanion

 

David Caro has proposed merging lp:~dcaro/clicompanion/fix-614789 into lp:clicompanion with lp:~dcaro/clicompanion/fix-913436 as a prerequisite.

Requested reviews:
  CLI Companion Development Team (clicompanion-devs)

For more details, see:
https://code.launchpad.net/~dcaro/clicompanion/fix-614789/+merge/88270

Fixed the copy-paste problem, now it is configured in the keybindings section.
-- 
https://code.launchpad.net/~dcaro/clicompanion/fix-614789/+merge/88270
Your team CLI Companion Development Team is requested to review the proposed merge of lp:~dcaro/clicompanion/fix-614789 into lp:clicompanion.
=== modified file 'clicompanionlib/config.py'
--- clicompanionlib/config.py	2012-01-11 20:44:29 +0000
+++ clicompanionlib/config.py	2012-01-11 20:44:29 +0000
@@ -83,6 +83,8 @@
         'toggle_fullscreen': 'F12',
         'toggle_maximize': 'F11',
         'toggle_hide_ui': 'F9',
+        'copy': 'shift+ctrl+C',
+        'paste': 'shift+ctrl+C',
         }
 
 ### funcname : labelname
@@ -101,6 +103,8 @@
         'toggle_fullscreen': 'Toggle fullscreen',
         'toggle_maximize': 'Maximize',
         'toggle_hide_ui': 'Hide UI',
+        'copy': 'Copy the selected text',
+        'paste': 'Paste the text in the terminal',
         }
 
 

=== modified file 'clicompanionlib/helpers.py'
--- clicompanionlib/helpers.py	2012-01-08 14:43:50 +0000
+++ clicompanionlib/helpers.py	2012-01-11 20:44:29 +0000
@@ -2,23 +2,23 @@
 # -*- coding: utf-8 -*-
 #
 # helpers.py - Helper dialogs for clicompanion
-#                                                                                                             
+#
 # Copyright 2012 Duane Hinnen, Kenny Meyer, Marcos Vanetta, Marek Bardoński,
 #                David Caro
-#                                                                                                             
-# This program is free software: you can redistribute it and/or modify it       
-# under the terms of the GNU General Public License version 3, as published     
-# by the Free Software Foundation.                                                                            
-#                                                                                                             
-# This program is distributed in the hope that it will be useful, but           
-# WITHOUT ANY WARRANTY; without even the implied warranties of                  
-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR            
-# PURPOSE.  See the GNU General Public License for more details.                
-#                                                                                                             
-# You should have received a copy of the GNU General Public License along       
-# with this program.  If not, see <http://www.gnu.org/licenses/>.               
-#    
-#    
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 3, as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranties of
+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+#
 ####
 ## This file keeps some popups that are shown across the program execution,
 ## that aren't directly related with a class, like the edit comand popup or the

=== modified file 'clicompanionlib/plugins.py'
--- clicompanionlib/plugins.py	2012-01-08 00:48:43 +0000
+++ clicompanionlib/plugins.py	2012-01-11 20:44:29 +0000
@@ -2,21 +2,21 @@
 # -*- coding: utf-8 -*-
 #
 # plugins.py - Plugin related clases for the clicompanion
-#                                                                                                             
+#
 # Copyright 2012 David Caro <david.caro.estevez@xxxxxxxxx>
-#                                                                                                             
-# This program is free software: you can redistribute it and/or modify it       
-# under the terms of the GNU General Public License version 3, as published     
-# by the Free Software Foundation.                                                                            
-#                                                                                                             
-# This program is distributed in the hope that it will be useful, but           
-# WITHOUT ANY WARRANTY; without even the implied warranties of                  
-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR            
-# PURPOSE.  See the GNU General Public License for more details.                
-#                                                                                                             
-# You should have received a copy of the GNU General Public License along       
-# with this program.  If not, see <http://www.gnu.org/licenses/>.               
-#    
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 3, as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranties of
+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 #################################################
 ## The plugins
 ##

=== modified file 'clicompanionlib/preferences.py'
--- clicompanionlib/preferences.py	2012-01-08 00:48:43 +0000
+++ clicompanionlib/preferences.py	2012-01-11 20:44:29 +0000
@@ -2,22 +2,22 @@
 # -*- coding: utf-8 -*-
 #
 # preferences.py - Preferences dialogs for clicompanion
-#                                                                                                             
+#
 # Copyright 2012 Duane Hinnen, Kenny Meyer, Marcos Vanettai, Marek Bardoński,
 #                David Caro <david.caro.estevez@xxxxxxxxx>
-#                                                                                                             
-# This program is free software: you can redistribute it and/or modify it       
-# under the terms of the GNU General Public License version 3, as published     
-# by the Free Software Foundation.                                                                            
-#                                                                                                             
-# This program is distributed in the hope that it will be useful, but           
-# WITHOUT ANY WARRANTY; without even the implied warranties of                  
-# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR            
-# PURPOSE.  See the GNU General Public License for more details.                
-#                                                                                                             
-# You should have received a copy of the GNU General Public License along       
-# with this program.  If not, see <http://www.gnu.org/licenses/>.               
-#    
+#
+# This program is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 3, as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranties of
+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
+# PURPOSE.  See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
 ############################################
 ## The preferences window is a popup that shows all the configuration options
 ## allowing the user to change them, also handles the profiles creatin and

=== modified file 'clicompanionlib/tabs.py'
--- clicompanionlib/tabs.py	2012-01-11 20:44:29 +0000
+++ clicompanionlib/tabs.py	2012-01-11 20:44:29 +0000
@@ -56,7 +56,7 @@
                              ()),
     }
 
-    def __init__(self, title, config, profile='default'):
+    def __init__(self, title, config, profile='default', directory=None):
         gtk.ScrolledWindow.__init__(self)
         self.config = config
         self.title = title
@@ -67,10 +67,17 @@
         self.update_records = self.config.getboolean(self.profile,
                                         'update_login_records')
         dbg('Updating login records: ' + self.update_records.__repr__())
-        self.vte.fork_command(cc_utils.shell_lookup(),
-           logutmp=self.update_records,
-           logwtmp=self.update_records,
-           loglastlog=self.update_records)
+        if directory:
+            self.pid = self.vte.fork_command(cc_utils.shell_lookup(),
+                                         logutmp=self.update_records,
+                                         logwtmp=self.update_records,
+                                         loglastlog=self.update_records,
+                                         directory=directory)
+        else:
+            self.pid = self.vte.fork_command(cc_utils.shell_lookup(),
+                                         logutmp=self.update_records,
+                                         logwtmp=self.update_records,
+                                         loglastlog=self.update_records)
         self.vte.connect("button_press_event", self.copy_paste_menu)
         self.update_config()
         self.show_all()
@@ -332,11 +339,16 @@
         if title == None:
             title = 'Tab %d' % self.gcp
 
-        newtab = TerminalTab(title, self.global_config)
-
+        cwd = None
         if self.get_n_pages() > 1:
             dbg('More than one tab, showing them.')
             self.set_show_tabs(True)
+            current_page = self.get_nth_page(self.get_current_page())
+            cwd = cc_utils.get_pid_cwd(current_page.pid)
+        if cwd:
+            newtab = TerminalTab(title, self.global_config, directory=cwd)
+        else:
+            newtab = TerminalTab(title, self.global_config)
         label = self.create_tab_label(title, newtab)
         self.insert_page(newtab, label, self.get_n_pages() - 1)
         self.set_current_page(self.get_n_pages() - 2)
@@ -430,3 +442,13 @@
         if not config:
             config = self.global_config
         tab.update_config(config)
+
+    def copy(self):
+        page = self.get_current_page()
+        term = self.get_nth_page(page)
+        term.vte.copy_clipboard()
+
+    def paste(self, text):
+        page = self.get_current_page()
+        term = self.get_nth_page(page)
+        term.vte.feed_child(text)

=== modified file 'clicompanionlib/utils.py'
--- clicompanionlib/utils.py	2012-01-08 00:48:43 +0000
+++ clicompanionlib/utils.py	2012-01-11 20:44:29 +0000
@@ -253,3 +253,14 @@
 
     def __init__(self):
         self.__dict__ = self.__shared_state
+
+
+def get_pid_cwd(pid):
+    """Extract the cwd of a PID from proc, given the PID and the /proc path to
+    insert it into, e.g. /proc/%s/cwd"""
+    try:
+        cwd = os.path.realpath('/proc/%s/cwd' % pid)
+    except Exception, ex:
+        dbg('Unable to get cwd for PID %s: %s' % (pid, ex))
+        cwd = '/'
+    return cwd

=== modified file 'clicompanionlib/view.py'
--- clicompanionlib/view.py	2012-01-11 20:44:29 +0000
+++ clicompanionlib/view.py	2012-01-11 20:44:29 +0000
@@ -184,7 +184,7 @@
             self.config = config
         newplugins = self.pluginloader.get_plugins('CommandTab')
         for plugin in self.loaded_plugins.keys():
-            if plugin not in [ name for name, cl in newplugins]:
+            if plugin not in [name for name, cl in newplugins]:
                 dbg('Disabling plugin %s' % plugin)
                 self.remove_page(self.page_num(self.loaded_plugins[plugin]))
                 self.loaded_plugins.pop(plugin)
@@ -212,6 +212,8 @@
         self.filtered = False
         self.fullscr = False
 
+        self.clipboard = gtk.clipboard_get(gtk.gdk.SELECTION_CLIPBOARD)
+
         self.config = config
 
         self.load_plugins()
@@ -460,6 +462,13 @@
     def previous_tab(self):
         self.term_notebook.prev_tab()
 
+    def copy(self):
+        self.term_notebook.copy()
+
+    def paste(self):
+        text = self.clipboard.wait_for_text() or ''
+        self.term_notebook.paste(text)
+
     def toggle_hide_ui(self):
         if self.hiddenui:
             self.show_ui()