Merge branch 'Ram-Z-min-char-hints'
This commit is contained in:
commit
8078068552
@ -141,12 +141,12 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* Brian Jackson
|
* Brian Jackson
|
||||||
* Patric Schmitz
|
* Patric Schmitz
|
||||||
* Johannes Altmanninger
|
* Johannes Altmanninger
|
||||||
|
* Samir Benmendil
|
||||||
* Regina Hug
|
* Regina Hug
|
||||||
* Mathias Fussenegger
|
* Mathias Fussenegger
|
||||||
* Larry Hynes
|
* Larry Hynes
|
||||||
* Thorsten Wißmann
|
* Thorsten Wißmann
|
||||||
* Thiago Barroso Perrotta
|
* Thiago Barroso Perrotta
|
||||||
* Samir Benmendil
|
|
||||||
* Matthias Lisin
|
* Matthias Lisin
|
||||||
* Helen Sherwood-Taylor
|
* Helen Sherwood-Taylor
|
||||||
* HalosGhost
|
* HalosGhost
|
||||||
|
@ -145,6 +145,7 @@
|
|||||||
|<<hints-opacity,opacity>>|Opacity for hints.
|
|<<hints-opacity,opacity>>|Opacity for hints.
|
||||||
|<<hints-mode,mode>>|Mode to use for hints.
|
|<<hints-mode,mode>>|Mode to use for hints.
|
||||||
|<<hints-chars,chars>>|Chars used for hint strings.
|
|<<hints-chars,chars>>|Chars used for hint strings.
|
||||||
|
|<<hints-min-chars,min-chars>>|Mininum number of chars used for hint strings.
|
||||||
|<<hints-uppercase,uppercase>>|Make chars in hint strings uppercase.
|
|<<hints-uppercase,uppercase>>|Make chars in hint strings uppercase.
|
||||||
|<<hints-auto-follow,auto-follow>>|Whether to auto-follow a hint if there's only one left.
|
|<<hints-auto-follow,auto-follow>>|Whether to auto-follow a hint if there's only one left.
|
||||||
|<<hints-next-regexes,next-regexes>>|A comma-separated list of regexes to use for 'next' links.
|
|<<hints-next-regexes,next-regexes>>|A comma-separated list of regexes to use for 'next' links.
|
||||||
@ -1191,6 +1192,12 @@ Chars used for hint strings.
|
|||||||
|
|
||||||
Default: +pass:[asdfghjkl]+
|
Default: +pass:[asdfghjkl]+
|
||||||
|
|
||||||
|
[[hints-min-chars]]
|
||||||
|
=== min-chars
|
||||||
|
Mininum number of chars used for hint strings.
|
||||||
|
|
||||||
|
Default: +pass:[1]+
|
||||||
|
|
||||||
[[hints-uppercase]]
|
[[hints-uppercase]]
|
||||||
=== uppercase
|
=== uppercase
|
||||||
Make chars in hint strings uppercase.
|
Make chars in hint strings uppercase.
|
||||||
|
@ -187,14 +187,20 @@ class HintManager(QObject):
|
|||||||
chars = '0123456789'
|
chars = '0123456789'
|
||||||
else:
|
else:
|
||||||
chars = config.get('hints', 'chars')
|
chars = config.get('hints', 'chars')
|
||||||
|
|
||||||
|
min_chars = config.get('hints', 'min-chars')
|
||||||
# Determine how many digits the link hints will require in the worst
|
# Determine how many digits the link hints will require in the worst
|
||||||
# case. Usually we do not need all of these digits for every link
|
# case. Usually we do not need all of these digits for every link
|
||||||
# single hint, so we can show shorter hints for a few of the links.
|
# single hint, so we can show shorter hints for a few of the links.
|
||||||
needed = math.ceil(math.log(len(elems), len(chars)))
|
needed = max(min_chars, math.ceil(math.log(len(elems), len(chars))))
|
||||||
# Short hints are the number of hints we can possibly show which are
|
# Short hints are the number of hints we can possibly show which are
|
||||||
# (needed - 1) digits in length.
|
# (needed - 1) digits in length.
|
||||||
short_count = math.floor((len(chars) ** needed - len(elems)) /
|
if needed > min_chars:
|
||||||
len(chars))
|
short_count = math.floor((len(chars) ** needed - len(elems)) /
|
||||||
|
len(chars))
|
||||||
|
else:
|
||||||
|
short_count = 0
|
||||||
|
|
||||||
long_count = len(elems) - short_count
|
long_count = len(elems) - short_count
|
||||||
|
|
||||||
strings = []
|
strings = []
|
||||||
|
@ -606,6 +606,10 @@ DATA = collections.OrderedDict([
|
|||||||
SettingValue(typ.String(minlen=2), 'asdfghjkl'),
|
SettingValue(typ.String(minlen=2), 'asdfghjkl'),
|
||||||
"Chars used for hint strings."),
|
"Chars used for hint strings."),
|
||||||
|
|
||||||
|
('min-chars',
|
||||||
|
SettingValue(typ.Int(minval=1), '1'),
|
||||||
|
"Mininum number of chars used for hint strings."),
|
||||||
|
|
||||||
('uppercase',
|
('uppercase',
|
||||||
SettingValue(typ.Bool(), 'false'),
|
SettingValue(typ.Bool(), 'false'),
|
||||||
"Make chars in hint strings uppercase."),
|
"Make chars in hint strings uppercase."),
|
||||||
|
Loading…
Reference in New Issue
Block a user