Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial format #201

Merged
merged 4 commits into from
Mar 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion caster/lib/ccr/core/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Navigation(MergeRule):
"peek format": R(Function(textformat.peek_text_format), rdescript="Peek Format"),
"(<capitalization> <spacing> | <capitalization> | <spacing>) (bow|bowel) <textnv> [brunt]": R(Function(textformat.master_format_text), rdescript="Text Format"),
"format <textnv>": R(Function(textformat.prior_text_format), rdescript="Last Text Format"),

"<word_limit> format <textnv>": R(Function(textformat.partial_format_text), rdescript="Partial Text Format"),
"dredge": R(Key("a-tab"), rdescript="Alt-Tab"),

}
Expand All @@ -167,6 +167,7 @@ class Navigation(MergeRule):
Choice("semi",
{"dock": ";", "doc": ";", "sink": ""
}),
Choice("word_limit",{"single": 1,"double": 2,"triple":3,"Quadra":4}),



Expand Down
6 changes: 5 additions & 1 deletion caster/lib/textformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ def get_text_format_description(capitalization, spacing):

def master_format_text(capitalization, spacing, textnv):
capitalization, spacing = normalize_text_format(capitalization, spacing)
Text(get_formatted_text(capitalization, spacing, str(textnv))).execute()
Text(get_formatted_text(capitalization, spacing, str(textnv))).execute()

def partial_format_text(word_limit,textnv):
global _CAPITALIZATION, _SPACING
Text(get_formatted_text(_CAPITALIZATION, _SPACING, " ".join(str(textnv).split(" ")[0:word_limit]))).execute()

def get_formatted_text(capitalization, spacing, t):
tlen = len(t)
Expand Down