- edited description
Refactor Input & InputBox in FileCommander
Input
, InputBox
and InputBoxmod
in FileCommander
differ little from their corresponding classes in Screens
and Components
, but have "inherited" from them by copy-paste-modify, leading to a lot of redundant code and the FileCommander not keeping up with changes to the corresponding classes in the main code.
The substantive differences between the FileCommander
and the corresponding main code classes are:
- In
FileCommander.InputBoxmod.Input
,handleAscii()
callsComponents.config.getCharValue(code)
, while the main code forInput
callsunichr(code)
instead. HowevergetCharValue()
doesn't work correctly (see bug#317). Other than that, the classes only really differ in the instance initialiser arguments. - In
FileCommander.InputBoxmod.InputBox
, the instance initialiser arguments differ from the main codeInputBox
(similar differences to those inInput
), and theFileCommander
code adds some additionalActionMap
actions, but only to existing methods. FileCommander.InputBoxmod.InputBoxmod
is a copy-paste-modify ofFileCommander.InputBoxmod.InputBox
that only actually changes the default skin to have a wide inputBox to use in theFileCommanders
's primitive text editor.FileCommander.InputBoxmod.PinInput
differs from the main codePinInput
in the same way thatInputBox
does.PinInput
(in either form) is not used inFileCommander
The two modules should be refactored to inherit from the corresponding main code classes. FileCommander.InputBoxmod.Input
should not over-ride Components.Input.handleAscii()
, but rather use the one in the base class. That will avoid bug #655, and allow Components.config.getCharValue()
to be removed from the code as suggested in issue #655.
The differences in the instance initialiser arguments could either be preserved, or changed to be the same as the main code classes, and the places where the objects are instantiated changed to correspond. The latter would allow FileCommander.InputBox.Input
to be removed entirely. Comment on that choice is sought.
The refactor of FileCommander.InputBox
was motivated by wanting to incorporate the fix to bug #317 into FileCommander
without further "inheritance by copy-paste". The refactor of FileCommander.InputBoxmod
followed by noticing that it had similar "inheritance by copy-paste".
Comments (8)
-
reporter -
- edited description
-
If you are going to attack this, then I think that the best strategy would be to eliminate as much code from
FileCommander
plugin as possible. If you have the opportunity to eliminateFileCommander.InputBox.Input
, go ahead. Just make sure that the result is maintainable and if there are any "gotchas", feel free to be generous with code comments. -
- changed status to resolved
Fix issue
#656: Refactor Input & InputBox in FileCommanderRemove module Plugins.Extensions.FileCommander.Input and re-base Plugins.Extensions.FileCommander.InputBoxmod.InputBox on Screens.InputBox.
The only functionality required in the new rebased InputBoxmod.InputBox is to add an ActionMap to it that supports the use of PLAY/PAUSE to toggle insert/overwrite.
The previous mappings of KEY_REWIND and KEY_FASTFORWARD to seekBack and seekForward and to the HOME and END actions on "break" respectively in the InfobarSeekActions context are made dummy actions, because the actions are already covered by mappings of the buttons to "home" and "end" on "make" in the KeyboardInputActions context in the ActionMap in Screens.InputBox.
The only functionality that InputBoxmod.InputBoxmod added is to provide a default skin, so it simply inherits from InputBoxmod.InputBox and adds the default skin.
InputBoxmod.PinInput is unused in FileCommander, so it has been removed. The old version only added similar functionality to that added by InputBoxmod.InputBox, and that extra functionality is probably unnecessary.
→ <<cset 6664508473e4>>
-
Fix issue
#656: Refactor Input & InputBox in FileCommander - module renameRename module Plugins.Extensions.FileCommander.InputBoxmod to Plugins.Extensions.FileCommander.InputBox.
Change imports of the module to match.
Remove unused import of InputBox from FileCommander/addons/type_utils.py.
Remove commented-out imports of InputBox, FileList and MultiFileSelectList from FileCommander/addons/key_actions.py.
→ <<cset 2779773f657a>>
-
Fix issue
#656: Refactor Input & InputBox in FileCommander - class renameRename class Plugins.Extensions.FileCommander.InputBox.InputBoxmod to Plugins.Extensions.FileCommander.InputBox.InputBoxWide, to match what its default skin allows.
Change imports of the cless to match.
→ <<cset 24d36142331e>>
-
Fix issue
#656: Refactor Input & InputBox in FileCommander - small cleanupRemove unused definition of EXTENSIONS dict from FileCommander/addons/type_utils.py.
→ <<cset a728300ba90a>>
-
Merged in prl/easy-ui-4/Fix-issue-656 (pull request #462)
Fix issue
#656: Refactor Input & InputBox in FileCommander→ <<cset 0c4100095ef3>>
- Log in to comment