Unified Command system

From TotalcmdWiki
Revision as of 08:43, 21 May 2005 by Lefteous (talk | contribs)
Jump to navigation Jump to search

There is currently no unified system to manage commands in Total Commander. Commands are internal commands (cm_*) and user-defined commands. The current system works but it's quite difficult to handle. A redesign should be made. The following list compares the current and a possible new system. The current system - Disadvantages of the current system:* User defined commands depend on start menu entries.

  • There is a hierarchy between menu hotkeys and user defined hotkeys.
  • Hotkeys in menus are not updated automatically. You have to do this manually.
  • Checkbox states in menus seems not to be part of an embedded system which enables automatic updating.
  • Check states for buttons are completely missing.
  • No separation between structure and language dependant information. This leads to redundancies and many other problems. Example: Exchanging of menu files doesn’t work very well. They contain language dependant captions and hotkeys.Benefits of a unified command system* A single point of access (the command manager) is presented to the user.
  • Commands are control independent. A command can be assigned to as many control as the user wants.
  • Implementing a system based on the observer pattern will solve the updating problem for all checkboxes, captions and all other properties in all controls.
  • Exchanging of user defined menus would be possible without or with much less translation.

Example: For example when I create a hotkey for a start menu entry (Ctrl+Alt+F7) and use the same entry for a hotkey assignment in configuration the start menu entry has a higher priority. A unified command system solves this problem. A user assigns a value to a command not to a control. This way hotkeys would be unique. Every time a user presses the hotkey the command is invoked. You may create a button, a menu item or whatever for the command but you don't have to if you just want a hotkey.

The command manager

I will add ideas and a prototype for a command manager here.

  • The user can compose the current menu from a list of menus. For example. A user defined menu is appended to the default menu and so on.


Command properties

A command should have the following properties:* Name - A unique name (identifier) for the command.

  • Caption: A caption which is shown in a control where the action is used.
  • Icon: A path to an icon.
  • Hotkey(s): One or more hotkeys which can be used to call the command.
  • Hint: A hint which can be shown to give more information about the action.
  • Category: Each command is assigned to a category.
  • Parameter: Some commands can have parameters.
  • Start path: For some commands a start path is required.
  • Window mode: For some commands a window mode makes sense (minimized, maximized, normal).
  • Run As: Executing a command as a diffrent user (Yes/no).


Design of involved files

Menu file. Example

[code][CTG_MARK] MENUITEM cm_spreadselection MENUITEM cm_shrinkselection [END_CTG][/code]

A menu starts with a category identifier. It ends with [END_CTG]. This only change from current to the new solution is that CTG is used instead of POPUP. Inside these markers we have the menu items. They just point to command identifiers. Language dependant captions and hotkeys are removed.

Predefined commands file. Example: [code][cm_SpreadSelection] ID=521 Category=CTG_MARK

[cm_ShrinkSelection] ID=522 Category=CTG_MARK[/code]Predefined commands have a static numeric ID. A category is assigned to a command as well. Categories in a menu or commands file can be the same but they don’t have to. It’s possible to add new categories in the menu file or use categories defined in the action file.

Userdefined command file. Example: [code][cm_CD_Pictures] Category=CTG_NAVIGATION Icon=%WINDIR%\System32\Shell32.dll,127[/code]The example shown above is a user defined action. It could have been created automatically by TC as the user created a directory menu item for example. Of course it has been sorted into the appropriate category CTG_NAVIGATION automatically. Please note that there is no ID set for the user defined command. Why? One aim of the unified command system is to make it easier to exchange user defined files like menu files, command files and others. Total Commander has to assign a ID dynamically for user defined commands. This has also the advantage that the user cannot assign an already assigned. This should be possible without huge speed problems.

Predefined Language file. Example: [code][CTG_MARK] Caption=&Mark Hint=Mark

[cm_SpreadSelection] Caption=&Select group Hint=Select group Description= Selects a group of files and folders based on a filter.[/code]I used caption and hint as two different properties as they are used in Delphi. This leads to a lot of redundancy. A good solution could be make hint optional and use the caption (without the ampersand) instead. This way you won’t get redundancies but still the opportunity to enter longer hints. On the other hand the description could be used for longer hints too. Maybe the hotkey can be moved to the language file. Why? Maybe English users prefare Ctrl+Q for “quick view” and german users want to use Ctrl+ S (Schnellansicht). There are pros and cons for this and can be discussed endlessly.

Userdefined language file. Example: [code][cm_CD_Pictures] Caption=&My Pictures Hint=My Pictures Description=[/code]The user defined language has the same structure as the predefined language file but contains translations for user defined commands.