Coverage for src/hods/tui/help.py: 100.00%

Shortcuts 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

27 statements  

1"""hods - home directory synchronization. 

2 

3Copyright (C) 2016-2020 Mathias Stelzer <knoppo@rolln.de> 

4 

5hods is free software: you can redistribute it and/or modify 

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

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

8(at your option) any later version. 

9 

10hods is distributed in the hope that it will be useful, 

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

12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

13GNU General Public License for more details. 

14 

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

16along with this program. If not, see <http://www.gnu.org/licenses/>. 

17""" 

18from hods.tui.base.view import TextWindow, Window 

19from hods.tui.base.widgets import DescriptionListBox 

20from hods.version import __version_info__ 

21 

22 

23class ControlsWindow(Window): 

24 """The controls window displaying available keys.""" 

25 

26 def __init__(self, app): 

27 """Initialize a `DescriptionList` to display the keys. 

28 

29 :param app: `hods.app.App` instance 

30 """ 

31 items = [ 

32 'General:', 

33 ('q, Q', 'Quit'), 

34 ('Esc', 'Close Window / Cancel / Quit'), 

35 ('r, R', 'Reload configuration'), 

36 '', 

37 ('F4', 'Pull configuration and sources'), 

38 ('F5', 'Update all files in home directory'), 

39 ('F9', 'Push configuration and sources'), 

40 '', 

41 'Features / Sources:', 

42 ('a', 'Add files to the selected source'), 

43 ('F7', 'Move selected feature/source down'), 

44 ('F8', 'Move selected feature/source up'), 

45 '', 

46 'File Tree:', 

47 ('+', 'Expand selected node'), 

48 ('-', 'Collapse selected node'), 

49 ('E', 'Expand all nodes'), 

50 ('C', 'Collapse all nodes'), 

51 ('PgUp', 'Select item one page above or first'), 

52 ('PgDn', 'Select item one page below or last'), 

53 ] 

54 self.description_list = DescriptionListBox(items, space=2) 

55 super().__init__(app, title='Controls', parent=app.config_columns, width=self.description_list.width + 4) 

56 

57 def get_body(self): 

58 """Get the main widget.""" 

59 return self.description_list 

60 

61 

62ABOUT_TEMPLATE = """ 

63Documentation: https://docs.rolln.de/knoppo/hods/{version}/ 

64 

65Code: https://rolln.de/knoppo/hods/""" 

66 

67 

68class AboutWindow(TextWindow): 

69 """The about window displaying the license.""" 

70 

71 def __init__(self, app): 

72 """Initialize window.""" 

73 lines = __doc__.splitlines() 

74 

75 dev_name = None 

76 short = '.'.join(str(v) for v in __version_info__[:2]) 

77 if __version_info__[3] == 'alpha': 

78 if __version_info__[4] == 0: 

79 dev_name = 'development' 

80 short = 'master' 

81 else: 

82 dev_name = 'alpha' 

83 elif __version_info__[3] == 'beta': 

84 dev_name = 'beta' 

85 

86 lines.insert(1, ABOUT_TEMPLATE.format(version=short)) 

87 if dev_name: 

88 lines.insert(1, '\n!!! THIS IS A {} VERSION !!!'.format(dev_name.upper())) 

89 super().__init__(app, '\n'.join(lines), title='About', parent=app.config_columns)