Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

# vim: ft=python fileencoding=utf-8 sts=4 sw=4 et: 

 

# Copyright 2017-2018 Ryan Roden-Corrent (rcorre) <ryan@rcorre.net> 

# 

# This file is part of qutebrowser. 

# 

# qutebrowser is free software: you can redistribute it and/or modify 

# it under the terms of the GNU General Public License as published by 

# the Free Software Foundation, either version 3 of the License, or 

# (at your option) any later version. 

# 

# qutebrowser is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU General Public License for more details. 

# 

# You should have received a copy of the GNU General Public License 

# along with qutebrowser. If not, see <http://www.gnu.org/licenses/>. 

 

"""Utility functions for completion models.""" 

 

from qutebrowser.utils import objreg, usertypes 

from qutebrowser.commands import cmdutils 

 

 

def get_cmd_completions(info, include_hidden, include_aliases, prefix=''): 

"""Get a list of completions info for commands, sorted by name. 

 

Args: 

info: The CompletionInfo. 

include_hidden: Include commands which are not in normal mode. 

include_aliases: True to include command aliases. 

prefix: String to append to the command name. 

 

Return: A list of tuples of form (name, description, bindings). 

""" 

assert cmdutils.cmd_dict 

cmdlist = [] 

cmd_to_keys = info.keyconf.get_reverse_bindings_for('normal') 

for obj in set(cmdutils.cmd_dict.values()): 

hide_debug = obj.debug and not objreg.get('args').debug 

hide_mode = (usertypes.KeyMode.normal not in obj.modes and 

not include_hidden) 

if not (hide_debug or hide_mode or obj.deprecated): 

bindings = ', '.join(cmd_to_keys.get(obj.name, [])) 

cmdlist.append((prefix + obj.name, obj.desc, bindings)) 

 

if include_aliases: 

for name, cmd in info.config.get('aliases').items(): 

bindings = ', '.join(cmd_to_keys.get(name, [])) 

cmdlist.append((name, "Alias for '{}'".format(cmd), bindings)) 

 

return sorted(cmdlist)