From 81af41d77f5453121507496fe5bb4c7a5cf394ad Mon Sep 17 00:00:00 2001 From: Samir Benmendil Date: Thu, 26 Feb 2015 00:47:49 +0000 Subject: [PATCH 1/3] Add option to set minimum number of chars in hints --- qutebrowser/browser/hints.py | 12 +++++++++--- qutebrowser/config/configdata.py | 4 ++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 6ecbf5dc5..cd42d9668 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -187,14 +187,20 @@ class HintManager(QObject): chars = '0123456789' else: chars = config.get('hints', 'chars') + + min_chars = config.get('hints', 'min-chars') # 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 # 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 # (needed - 1) digits in length. - short_count = math.floor((len(chars) ** needed - len(elems)) / - len(chars)) + if needed > min_chars: + short_count = math.floor((len(chars) ** needed - len(elems)) / + len(chars)) + else: + short_count = 0 + long_count = len(elems) - short_count strings = [] diff --git a/qutebrowser/config/configdata.py b/qutebrowser/config/configdata.py index 230187a91..787b6b040 100644 --- a/qutebrowser/config/configdata.py +++ b/qutebrowser/config/configdata.py @@ -606,6 +606,10 @@ DATA = collections.OrderedDict([ SettingValue(typ.String(minlen=2), 'asdfghjkl'), "Chars used for hint strings."), + ('min-chars', + SettingValue(typ.Int(minval=1), '1'), + "Mininum number of chars used for hint strings."), + ('uppercase', SettingValue(typ.Bool(), 'false'), "Make chars in hint strings uppercase."), From 0d9bf5e2c959919aca897e60d93dc0e2a919f5a9 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 26 Feb 2015 06:13:27 +0100 Subject: [PATCH 2/3] Fix lint. --- qutebrowser/browser/hints.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index cd42d9668..6e6e0f932 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -197,7 +197,7 @@ class HintManager(QObject): # (needed - 1) digits in length. if needed > min_chars: short_count = math.floor((len(chars) ** needed - len(elems)) / - len(chars)) + len(chars)) else: short_count = 0 From f91aaf778ae9abba6e0036c6bf41551fd753f6bf Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 26 Feb 2015 06:13:58 +0100 Subject: [PATCH 3/3] Regenerate docs. --- README.asciidoc | 2 +- doc/help/settings.asciidoc | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/README.asciidoc b/README.asciidoc index 80628fd8f..383967da2 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -141,12 +141,12 @@ Contributors, sorted by the number of commits in descending order: * Brian Jackson * Patric Schmitz * Johannes Altmanninger +* Samir Benmendil * Regina Hug * Mathias Fussenegger * Larry Hynes * Thorsten Wißmann * Thiago Barroso Perrotta -* Samir Benmendil * Matthias Lisin * Helen Sherwood-Taylor * HalosGhost diff --git a/doc/help/settings.asciidoc b/doc/help/settings.asciidoc index 36534a53e..36088137a 100644 --- a/doc/help/settings.asciidoc +++ b/doc/help/settings.asciidoc @@ -145,6 +145,7 @@ |<>|Opacity for hints. |<>|Mode to use for hints. |<>|Chars used for hint strings. +|<>|Mininum number of chars used for hint strings. |<>|Make chars in hint strings uppercase. |<>|Whether to auto-follow a hint if there's only one left. |<>|A comma-separated list of regexes to use for 'next' links. @@ -1191,6 +1192,12 @@ Chars used for hint strings. Default: +pass:[asdfghjkl]+ +[[hints-min-chars]] +=== min-chars +Mininum number of chars used for hint strings. + +Default: +pass:[1]+ + [[hints-uppercase]] === uppercase Make chars in hint strings uppercase.