Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #16049
| From | Arturas Acus <arturas.acus@tfai.vu.lt> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | universal shortcut |
| Date | 2013-10-11 08:53 +0000 |
| Message-ID | <l38eac$j1o$1@smc.vnet.net> (permalink) |
| Organization | Time-Warner Telecom |
Dear Group,
despite my rather long experience with Mathematica I was never satisfied with
palettes or shortcuts ideas to input nice formated symbols in Mathematica. The
first is too slow, the second requires to remember a lot of
abbreviations. From the other side Shift + K idea (universal completion
template) I found rather useful. So I would like to implement something
like universal "shortcut" (well, say for simple heads with fixed number
of arguments at least). Consider for example the following particular
shortcut:
SetOptions[System`$FrontEndSession,
InputAliases ->
Fold[DeleteCases,
CurrentValue[System`$FrontEndSession, InputAliases],
Thread[Rule[{"mvb"}, Blank[]]]]]
$GAPackageInputAliases = {};
$GAPackageInputAliases =
Join[$GAPackageInputAliases, {"mvb" ->
RowBox[{TemplateBox[{TemplateBox[{TagBox[FrameBox["index"],
"Placeholder"]}, "GADown",
DisplayFunction -> (SubscriptBox["\[InvisibleSpace]",
RowBox[{##, "\[InvisibleSpace]"}]] &)],
"RunningAlgebra"}, "\[DoubleStruckE]",
DisplayFunction -> (RowBox[{StyleBox["\[DoubleStruckE]",
RGBColor[0, 0, 0]], "\[InvisibleSpace]", #}] &)]}] }];
SetOptions[System`$FrontEndSession,
InputAliases ->
Join[CurrentValue[System`$FrontEndSession,
InputAliases], $GAPackageInputAliases]];
with the following definitions
MakeBoxes[GADown[in__], StandardForm] :=
With[{pf =
Function @@ {SubscriptBox["\[InvisibleSpace]",
RowBox[Riffle[Slot /@ Range[Length[{in}]],
"\[InvisibleSpace]"]]]}},
TemplateBox[MakeBoxes /@ {in}, "GADown", DisplayFunction -> pf,
SyntaxForm -> SubscriptBox, Tooltip -> ToString[GADown[in]]]]
MakeBoxes[\[DoubleStruckE][in__, ra_Cl], StandardForm] :=
With[{pf =
Function @@ {RowBox[
Join[{StyleBox["\[DoubleStruckE]", GAStyle[ra]],
"\[InvisibleSpace]"},
Riffle[Slot /@ Range[Length[{in}]], "\[InvisibleSpace]"]]]}},
TemplateBox[MakeBoxes /@ {in, ra}, "\[DoubleStruckE]",
DisplayFunction -> pf, SyntaxForm -> RowBox, Tooltip -> None]] /;
MemberQ[GAStyle[ra], _Rule]
SetAttributes[upgradeInputAlias, HoldRest];
upgradeInputAlias[aliasName_String, aliasReplacementRul__Rule] :=
Module[{inpOpt, alposition},
SetOptions[System`$FrontEndSession,
ReplacePart[
inpOpt =
Options[System`$FrontEndSession,
InputAliases], (alposition =
Position[inpOpt, aliasName -> _][[1]]) -> (Extract[inpOpt,
alposition] /. {aliasReplacementRul})]]]
Options[DefineGeometricAlgebra] = {FontColor -> Automatic};
DefineGeometricAlgebra[{p_Integer, q_Integer, r_Integer: 0},
opts___?OptionQ] := (
RunningAlgebra = Cl[p, q, r];
GAStyle[
Cl[p, q, r]] = {FontColor ->
Module[{value},
Switch[value = ((FontColor /.
FilterRules[{opts}, Options[StyleBox]]) /.
Options[DefineGeometricAlgebra]), _RGBColor, value,
Automatic, RGBColor[p, r, q], _, Black]]};
upgradeInputAlias["mvb",
RGBColor[__] -> (FontColor /. GAStyle[Cl[p, q, r]])];
upgradeInputAlias["mvb", "RunningAlgebra" -> MakeBoxes[Cl[p, q, r]]];
)
Now if we define
DefineGeometricAlgebra[{5, 3, 0}]
then input shortcut <esc>mvb<esc> seems work nice.
Suppose now that I don't want to remember what "mvb" means. Instead I
would like to start typing container name i.e. \[DoubleStruckE] and
then pres some universal combination like Shift + ctrl + W or any other
not reserved, and this will look in defined input aliases (or You can
think any other idea) and insert Template box matching
\[DoubleStruckE] .
Can the idea of "universal shortcut" or "supershorcut" be implemented?
The Mathematica expression completion description is rather sketchy.
Sincerely, Arturas Acus
Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread
universal shortcut Arturas Acus <arturas.acus@tfai.vu.lt> - 2013-10-11 08:53 +0000
csiph-web