Skip to content

Commit

Permalink
Merge pull request #266 from comodoro/totalcmd
Browse files Browse the repository at this point in the history
Add Total Commander rule
  • Loading branch information
LexiconCode authored Oct 6, 2018
2 parents 41f776e + 2627553 commit f740d33
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
119 changes: 119 additions & 0 deletions caster/apps/totalcmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from dragonfly import (Grammar, AppContext, Dictation, Key, Repeat)

from caster.lib import control
from caster.lib import settings
from caster.lib.dfplus.additions import IntegerRefST
from caster.lib.dfplus.merge import gfilter
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R


class TotalCommanderRule (MergeRule):
pronunciation = "total commander"

mapping = {
"find [in] files":
R(Key('a-f7'),
rdescript="Total Commander: find"),
"view":
R(Key('f3'),
rdescript="Total Commander: find next/view file"),
"edit":
R(Key('f4'),
rdescript="Total Commander: edit file"),
"copy":
R(Key('f5'),
rdescript="Total Commander: copy"),
"move":
R(Key('f6'),
rdescript="Total Commander: move file"),
"new directory":
R(Key('f7'),
rdescript="Total Commander: create directory"),
"wipe":
R(Key('s-delete'),
rdescript="Total Commander: really delete file"),
"FTP":
R(Key('c-f'),
rdescript="Total Commander: Connect to FTP"),
"synchronize":
R(Key('a-c') + Key('y'),
rdescript="Total Commander: synchronize dirs"),
"sort by name":
R(Key('c-f3'),
rdescript="Total Commander: sort files by name"),
"sort by extension":
R(Key('c-f4'),
rdescript="Total Commander: sort files by extension"),
"sort by date":
R(Key('c-f5'),
rdescript="Total Commander: sort files by date"),
"sort by size":
R(Key('c-f6'),
rdescript="Total Commander: sort files by size"),
"file filter":
R(Key('c-f12'),
rdescript="Total Commander: filter files"),
"new tab":
R(Key('c-t'),
rdescript="Total Commander: new tab"),
"multi rename":
R(Key('c-m'),
rdescript="Total Commander: batch rename files"),
"display thumbnails":
R(Key('cs-f1'),
rdescript="Total Commander: display thumbnails in panel"),
"display list":
R(Key('c-f1'),
rdescript="Total Commander: display plain file list in panel"),
"display details":
R(Key('c-f2'),
rdescript="Total Commander: display details in panel"),
"display file tree":
R(Key('c-f8'),
rdescript="Total Commander: display file tree in panel"),
}

class SyncDirsRule (MergeRule):
pronunciation = "total commander synchronize directories"

mapping = {
"compare files":
R(Key('c-f3'),
rdescript="Sync Dirs: compare right and left"),
"copy left":
R(Key('c-l'),
rdescript="Sync Dirs: select for copying left"),
"copy right":
R(Key('c-r'),
rdescript="Sync Dirs: select for copying right"),
"view right":
R(Key('s-f3'),
rdescript="Sync Dirs: view right"),
"remove selection":
R(Key('c-m'),
rdescript="Sync Dirs: remove selection"),
"synchronize":
R(Key('a-c'),
rdescript="Total Commander: synchronize button"),
}

context = AppContext(executable="totalcmd") | AppContext(executable="totalcmd64")
grammar = Grammar("Total Commander", context=context)
syncdir_context = AppContext(executable="totalcmd", title='Synchronize directories')
syncdir_context |= AppContext(executable="totalcmd64", title='Synchronize directories')
syncdir_grammar = Grammar("Total Commander Sync Dirs", context=syncdir_context)

if settings.SETTINGS["apps"]["totalcmd"]:
if settings.SETTINGS["miscellaneous"]["rdp_mode"]:
control.nexus().merger.add_global_rule(SyncDirsRule())
control.nexus().merger.add_global_rule(TotalCommanderRule())
else:
syncdir_rule = SyncDirsRule(name="totalcmd sync dirs")
gfilter.run_on(syncdir_rule)
syncdir_grammar.add_rule(syncdir_rule)
syncdir_grammar.load()
rule = TotalCommanderRule(name="totalcmd")
gfilter.run_on(rule)
grammar.add_rule(rule)
grammar.load()
1 change: 1 addition & 0 deletions caster/lib/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ def _find_natspeak():
"ssms": True,
"jetbrains": True,
"msvc": True,
"totalcmd": True,
"notepadplusplus": True,
"sqldeveloper": True,
"sublime": True,
Expand Down

0 comments on commit f740d33

Please sign in to comment.