Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/robotframework/RIDE
Browse files Browse the repository at this point in the history
  • Loading branch information
Tattoo committed Aug 27, 2012
2 parents f44a953 + 2231917 commit e22d633
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
11 changes: 9 additions & 2 deletions src/robotide/action/shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,14 @@
'Down': DOWN_CHAR
}

def replace_mac_chars(string):
def localize_shortcuts(string):
if IS_MAC:
string = string.replace('CtrlCmd', 'Cmd')
else:
string = string.replace('CtrlCmd', 'Ctrl')
return _replace_mac_chars(string)

def _replace_mac_chars(string):
if not IS_MAC or not string:
return string
for key, value in _REPLACE.items():
Expand All @@ -65,7 +72,7 @@ def _get_printable(self, value):
return self._replace_chars_in_mac(value)

def _replace_chars_in_mac(self, shortcut):
return replace_mac_chars(shortcut)
return _replace_mac_chars(shortcut)

def __nonzero__(self):
return bool(self.value)
Expand Down
6 changes: 3 additions & 3 deletions src/robotide/context/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,15 +261,15 @@
<th><b>What it does</b></th>
</tr>
<tr>
<td>Ctrl-C</td>
<td>CtrlCmd-C</td>
<td>Copy from text output when text selected</td>
</tr>
<tr>
<td>Ctrl-L</td>
<td>CtrlCmd-L</td>
<td>Open HTML log</td>
</tr>
<tr>
<td>Ctrl-R</td>
<td>CtrlCmd-R</td>
<td>Show HTML report</td>
</tr>
</table>
Expand Down
13 changes: 7 additions & 6 deletions src/robotide/contrib/testrunner/testrunnerplugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from robot.output import LEVELS
from robot.utils.encoding import SYSTEM_ENCODING
from robot.utils.encodingsniffer import DEFAULT_OUTPUT_ENCODING
from robotide.action.shortcut import localize_shortcuts
from robotide.contrib.testrunner.runprofiles import CustomScriptProfile
from robotide.controller.testexecutionresults import TestExecutionResults
from robotide.publish.messages import (RideDataFileSet, RideDataFileRemoved, RideFileNameChanged,
Expand Down Expand Up @@ -141,9 +142,9 @@ def __init__(self, application=None):
self._min_log_level_number = LEVELS['INFO']

def _register_shortcuts(self):
self.register_shortcut('Ctrl-C', self._copy_from_out)
self.register_shortcut('Ctrl-L', self.OnShowLog)
self.register_shortcut('Ctrl-R', self.OnShowReport)
self.register_shortcut('CtrlCmd-C', self._copy_from_out)
self.register_shortcut('CtrlCmd-L', self.OnShowLog)
self.register_shortcut('CtrlCmd-R', self.OnShowReport)
if IS_WINDOWS or IS_MAC:
self.register_shortcut('Del', self._delete_pressed)

Expand Down Expand Up @@ -178,7 +179,7 @@ def _register_actions(self):
"F8", getRobotBitmap(), "Run the selected tests")
self._run_action = self.register_action(run_action_info)
stop_action_info = ActionInfo("Tools", "Stop Running", self.OnStop, None,
"Ctrl-F8", getProcessStopBitmap(), "Stop a running test")
"CtrlCmd-F8", getProcessStopBitmap(), "Stop a running test")
self._stop_action = self.register_action(stop_action_info)

def _read_run_profiles(self):
Expand Down Expand Up @@ -603,9 +604,9 @@ def _build_local_toolbar(self):
longHelp="Stop a running test")
toolbar.AddSeparator()
toolbar.AddLabelTool(ID_SHOW_REPORT, " Report", reportImage,
shortHelp = "View Robot Report in Browser (Ctrl-R)")
shortHelp = localize_shortcuts("View Robot Report in Browser (CtrlCmd-R)"))
toolbar.AddLabelTool(ID_SHOW_LOG, " Log", logImage,
shortHelp = "View Robot Log in Browser (Ctrl-L)")
shortHelp = localize_shortcuts("View Robot Log in Browser (CtrlCmd-L)"))
toolbar.AddSeparator()
# the toolbar API doesn't give us a way to specify padding which
# is why the label has a couple spaces after the colon. gross,
Expand Down
18 changes: 12 additions & 6 deletions src/robotide/editor/texteditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def enable(self):
def _register_shortcuts(self):
def focused(func):
def f(event):
if self.is_focused() and (self._editor == wx.Window.FindFocus()):
if self.is_focused() and self._editor.is_focused():
func(event)
return f
#NOTE: Do not keep hard reference to _editor as it can change if plugin is disabled and enabled!
Expand Down Expand Up @@ -253,6 +253,10 @@ def __init__(self, parent, title, data_validator):
self._data = None
self._dirty = False

def is_focused(self):
foc = wx.Window.FindFocus()
return any(elem == foc for elem in [self]+list(self.GetChildren()))

def _create_ui(self, title):
self.SetSizer(VerticalSizer())
self._create_editor_toolbar()
Expand Down Expand Up @@ -293,14 +297,16 @@ def OnFindBackwards(self, event):

def _find(self, forward=True):
txt = self._search_field.GetValue()
anchor = self._editor.GetAnchor()
file_end = len(self._editor.utf8_text)
position = self._find_text_position(anchor, file_end, forward, txt)
position = self._find_text_position(forward, txt)
self._show_search_results(position, txt)

def _find_text_position(self, anchor, file_end, forward, txt):
# FIXME: This must be cleaned up
def _find_text_position(self, forward, txt):
file_end = len(self._editor.utf8_text)
search_end = file_end if forward else 0
position = self._editor.FindText(anchor + 1, search_end, txt, 0)
anchor = self._editor.GetAnchor()
anchor += 1 if forward else 0
position = self._editor.FindText(anchor, search_end, txt, 0)
if position == -1:
start, end = (0, file_end) if forward else (file_end - 1, 0)
position = self._editor.FindText(start, end, txt, 0)
Expand Down
6 changes: 2 additions & 4 deletions src/robotide/ui/mainframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
InitFileFormatDialog)
from .review import ReviewDialog
from .pluginmanager import PluginManager
from robotide.action.shortcut import replace_mac_chars
from robotide.action.shortcut import localize_shortcuts
from .tree import Tree
from .notebook import NoteBook
from .progress import LoadProgressObserver
Expand Down Expand Up @@ -359,6 +359,4 @@ def OnKey(self, *args):
pass

def _get_platform_specific_shortcut_keys(self):
if IS_MAC:
return replace_mac_chars(SHORTCUT_KEYS.replace('CtrlCmd', 'Cmd'))
return SHORTCUT_KEYS.replace('CtrlCmd', 'Ctrl')
return localize_shortcuts(SHORTCUT_KEYS)

0 comments on commit e22d633

Please sign in to comment.