7155567 sysconfig create-profile exception if F9 and Cancel at Help Topic screen
authorDrew Fisher <drew.fisher@oracle.com>
Wed, 02 May 2012 08:08:25 -0600
changeset 1662 b5c7fd54a90b
parent 1661 545e3b001fca
child 1663 fcaba03e9aba
7155567 sysconfig create-profile exception if F9 and Cancel at Help Topic screen 7161344 ScrollWindows should support letter jumping 7161999 Obselete TGT_ERROR in usr/src/cmd/text-install/disk_selection.py
usr/src/cmd/system-config/timezone.py
usr/src/cmd/text-install/disk_selection.py
usr/src/lib/terminalui/scroll_window.py
--- a/usr/src/cmd/system-config/timezone.py	Fri Apr 27 08:01:37 2012 -0700
+++ b/usr/src/cmd/system-config/timezone.py	Wed May 02 08:08:25 2012 -0600
@@ -141,7 +141,8 @@
         area.columns = self.win_size_x
         LOGGER.debug("area.lines=%s, area.columns=%s",
                       area.lines, area.columns)
-        self.scroll_region = ScrollWindow(area, window=self.center_win)
+        self.scroll_region = ScrollWindow(area, enable_spelldict=True,
+                                          window=self.center_win)
         
         utc = 0
         if self.screen == TimeZone.REGIONS:
@@ -150,12 +151,16 @@
             utc_item = ListItem(utc_area, window=self.scroll_region,
                                 text=TimeZone.UTC_TEXT,
                                 data_obj=SystemInfo.UTC)
+            self.scroll_region.spell_dict[TimeZone.UTC_TEXT] = utc
             utc = 1
         
         # add the entries to the screen
         for idx, timezone in enumerate(tz_list):
+            # add this timezone to the scroll_region's spelling dict
+            self.scroll_region.spell_dict[timezone.lower()] = idx + utc
+
             LOGGER.log(LOG_LEVEL_INPUT, "tz idx = %i name= %s",
-                        idx, tz_list[idx])
+                       idx, tz_list[idx])
             hilite = min(menu_item_max_width, len(timezone) + 1)
             win_area = WindowArea(1, hilite, idx + utc, TimeZone.SCROLL_SIZE)
             list_item = ListItem(win_area, window=self.scroll_region,
--- a/usr/src/cmd/text-install/disk_selection.py	Fri Apr 27 08:01:37 2012 -0700
+++ b/usr/src/cmd/text-install/disk_selection.py	Wed May 02 08:08:25 2012 -0600
@@ -92,9 +92,6 @@
     NO_DISKS = _("No disks found. Additional device drivers may "
                  "be needed.")
     NO_TARGETS = _("%(release)s cannot be installed on any disk") % RELEASE
-    TGT_ERROR = _("An error occurred while searching for installation"
-                  " targets. Please check the install log and file a bug"
-                  " at defect.opensolaris.org.")
 
     DISK_HEADERS = [(8, _("Type")),
                     (10, _(" Size(GB)")),
--- a/usr/src/lib/terminalui/scroll_window.py	Fri Apr 27 08:01:37 2012 -0700
+++ b/usr/src/lib/terminalui/scroll_window.py	Wed May 02 08:08:25 2012 -0600
@@ -19,7 +19,7 @@
 #
 # CDDL HEADER END
 #
-# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
 #
 
 '''
@@ -28,8 +28,10 @@
 '''
 
 import curses
+import string
 
 import terminalui
+
 from terminalui import LOG_LEVEL_INPUT
 from terminalui.inner_window import InnerWindow
 
@@ -60,8 +62,7 @@
         self.window.touchwin()
         for win in self.more_windows:
             win.touchwin()
-        for obj in self.all_objects:
-            obj.redrawwin()
+                
         self.no_ut_refresh()
 
     def _init_win(self, parent):
@@ -83,7 +84,7 @@
         self.area.lower_right_y = self.area.y_loc + self.area.lines
         self.area.lower_right_x = self.area.x_loc + self.area.columns
 
-    def __init__(self, area, **kwargs):
+    def __init__(self, area, enable_spelldict=False, **kwargs):
         '''ScrollWindow Constructor. See also InnerWindow.__init__
 
         area (required) - For ScrollWindows, area.scrollable_lines
@@ -113,6 +114,16 @@
         self.key_dict[curses.KEY_DOWN] = self.on_arrow_key
         self.key_dict[curses.KEY_LEFT] = self.on_arrow_key
         self.key_dict[curses.KEY_RIGHT] = self.on_arrow_key
+        if enable_spelldict:
+            # add 'space' (ascii value 32), '-' (value 45) and backspace to the
+            # key_dict
+            self.key_dict[32] = self.on_letter_key
+            self.key_dict[45] = self.on_letter_key
+            self.key_dict[curses.KEY_BACKSPACE] = self.on_letter_key
+            self.key_dict.update(dict.fromkeys(map(ord, string.lowercase),
+                                               self.on_letter_key))
+        self.spell_dict = dict()
+        self.spell_str = ""
 
     def set_use_vert_scroll_bar(self, use_vert_scroll_bar):
         '''Setter for self.use_vert_scroll_bar. Triggers a redraw of
@@ -272,11 +283,36 @@
                              max(0, self.current_line[1]))
         self.no_ut_refresh()
 
+    def on_letter_key(self, input_key):
+        '''Activate the object whose first letter corresponds to the key
+        pressed
+        
+        '''
+        # reset the spell string if the user presses <backspace>
+        if input_key == curses.KEY_BACKSPACE:
+            self.spell_str = ""
+            return None
+
+        # add this letter to the spelling list
+        self.spell_str += chr(input_key)
+
+        # look for this entry in the spell_dict
+        for entry in sorted(self.spell_dict):
+            if entry.startswith(self.spell_str):
+                self.activate_object_force(self.spell_dict[entry],
+                                           force_to_top=True)
+                return None
+        else:
+            return input_key
+
     def on_arrow_key(self, input_key):
         '''Activate the next/previous object, or, for pure text windows, simply
         scroll down/up one line or right/left one column
 
         '''
+        # reset the spell string
+        self.spell_str = ""
+
         offset = ScrollWindow.ARROW_DICT[input_key][0]
         at_endpt = getattr(self, ScrollWindow.ARROW_DICT[input_key][1])
         if self.active_object is not None: