hspylib-clitt 0.9.47__tar.gz → 0.9.49__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of hspylib-clitt might be problematic. Click here for more details.

Files changed (99) hide show
  1. {hspylib-clitt-0.9.47/hspylib_clitt.egg-info → hspylib-clitt-0.9.49}/PKG-INFO +2 -2
  2. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/README.md +1 -1
  3. hspylib-clitt-0.9.49/clitt/.version +1 -0
  4. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/__classpath__.py +1 -1
  5. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/__init__.py +2 -2
  6. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/__init__.py +2 -2
  7. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/__init__.py +2 -2
  8. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/appman.py +1 -1
  9. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/__init__.py +2 -2
  10. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/__init__.py +2 -2
  11. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widgets/__init__.py +2 -2
  12. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/__init__.py +3 -3
  13. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/__init__.py +2 -2
  14. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/emojis/__init__.py +2 -2
  15. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/__init__.py +2 -2
  16. hspylib-clitt-0.9.49/clitt/core/term/__init__.py +14 -0
  17. hspylib-clitt-0.9.49/clitt/core/term/commons.py +63 -0
  18. {hspylib-clitt-0.9.47/clitt/core/tty → hspylib-clitt-0.9.49/clitt/core/term}/cursor.py +5 -4
  19. {hspylib-clitt-0.9.47/clitt/core/tty → hspylib-clitt-0.9.49/clitt/core/term}/screen.py +8 -12
  20. {hspylib-clitt-0.9.47/clitt/core/tty → hspylib-clitt-0.9.49/clitt/core/term}/terminal.py +24 -65
  21. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/__init__.py +2 -2
  22. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mchoose/__init__.py +2 -2
  23. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mchoose/menu_choose.py +2 -2
  24. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mdashboard/__init__.py +2 -2
  25. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mdashboard/menu_dashboard.py +2 -2
  26. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/__init__.py +2 -2
  27. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu_item.py +2 -2
  28. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu_ui.py +3 -4
  29. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu_view.py +1 -1
  30. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/__init__.py +2 -2
  31. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/menu_input.py +4 -3
  32. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/minput_utils.py +1 -1
  33. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mselect/__init__.py +2 -2
  34. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mselect/menu_select.py +2 -2
  35. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/table/__init__.py +2 -2
  36. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/table/table_renderer.py +10 -14
  37. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/tui_application.py +11 -5
  38. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/tui_component.py +21 -17
  39. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/tui_preferences.py +3 -0
  40. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/utils/__init__.py +2 -2
  41. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49/hspylib_clitt.egg-info}/PKG-INFO +2 -2
  42. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/hspylib_clitt.egg-info/SOURCES.txt +5 -5
  43. hspylib-clitt-0.9.47/clitt/.version +0 -1
  44. hspylib-clitt-0.9.47/clitt/core/tty/__init__.py +0 -14
  45. hspylib-clitt-0.9.47/clitt/core/tty/tty_types.py +0 -11
  46. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/MANIFEST.in +0 -0
  47. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/__main__.py +0 -0
  48. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/appman_enums.py +0 -0
  49. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/build.gradle.tpl +0 -0
  50. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/classpath.py.tpl +0 -0
  51. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/dependencies.hspd.tpl +0 -0
  52. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/gitignore.tpl +0 -0
  53. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/main.py.tpl +0 -0
  54. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/main_qt.py.tpl +0 -0
  55. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/main_qt_view.py.tpl +0 -0
  56. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/main_qt_view.ui.tpl +0 -0
  57. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/run.sh.tpl +0 -0
  58. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/test_main.py.tpl +0 -0
  59. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/usage.txt.tpl +0 -0
  60. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/appman/templates/widget.py.tpl +0 -0
  61. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widget.py +0 -0
  62. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widget_entry.py +0 -0
  63. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widgets/widget_free.py +0 -0
  64. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widgets/widget_punch.py +0 -0
  65. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widgets/widget_send_msg.py +0 -0
  66. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widgets/widget_time_calc.py +0 -0
  67. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/addons/widman/widman.py +0 -0
  68. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/emojis/emojis.py +0 -0
  69. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/emojis/face_smiling.py +0 -0
  70. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/app_icons.py +0 -0
  71. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/awesome.py +0 -0
  72. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/control_icons.py +0 -0
  73. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/dashboard_icons.py +0 -0
  74. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/form_icons.py +0 -0
  75. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/nav_icons.py +0 -0
  76. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/icons/font_awesome/widget_icons.py +0 -0
  77. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mchoose/mchoose.py +0 -0
  78. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mdashboard/dashboard_builder.py +0 -0
  79. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mdashboard/dashboard_item.py +0 -0
  80. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mdashboard/mdashboard.py +0 -0
  81. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu.py +0 -0
  82. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu_action.py +0 -0
  83. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/menu/tui_menu_factory.py +0 -0
  84. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/access_type.py +0 -0
  85. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/field_builder.py +0 -0
  86. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/form_builder.py +0 -0
  87. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/form_field.py +0 -0
  88. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/input_type.py +0 -0
  89. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/input_validator.py +0 -0
  90. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/minput/minput.py +0 -0
  91. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/mselect/mselect.py +0 -0
  92. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/core/tui/table/table_enums.py +0 -0
  93. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/utils/git_utils.py +0 -0
  94. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/clitt/welcome.txt +0 -0
  95. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/hspylib_clitt.egg-info/dependency_links.txt +0 -0
  96. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/hspylib_clitt.egg-info/requires.txt +0 -0
  97. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/hspylib_clitt.egg-info/top_level.txt +0 -0
  98. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/setup.cfg +0 -0
  99. {hspylib-clitt-0.9.47 → hspylib-clitt-0.9.49}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hspylib-clitt
3
- Version: 0.9.47
3
+ Version: 0.9.49
4
4
  Summary: HsPyLib - CLI Terminal Tools
5
5
  Home-page: https://github.com/yorevs/hspylib
6
6
  Author: Hugo Saporetti Junior
@@ -30,7 +30,7 @@ Description-Content-Type: text/markdown
30
30
  ## Create professional CLI applications
31
31
 
32
32
  [![License](https://badgen.net/badge/license/MIT/gray)](LICENSE.md)
33
- [![Release](https://badgen.net/badge/release/v0.9.47/gray)](CHANGELOG.md#unreleased)
33
+ [![Release](https://badgen.net/badge/release/v0.9.49/gray)](CHANGELOG.md#unreleased)
34
34
  [![PyPi](https://badgen.net/badge/icon/python?icon=pypi&label)](https://pypi.org/project/hspylib-clitt)
35
35
  [![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com/yorevs/hspylib)
36
36
  [![Gitter](https://badgen.net/badge/icon/gitter?icon=gitter&label)](https://gitter.im/hspylib/community)
@@ -3,7 +3,7 @@
3
3
  ## Create professional CLI applications
4
4
 
5
5
  [![License](https://badgen.net/badge/license/MIT/gray)](LICENSE.md)
6
- [![Release](https://badgen.net/badge/release/v0.9.47/gray)](CHANGELOG.md#unreleased)
6
+ [![Release](https://badgen.net/badge/release/v0.9.49/gray)](CHANGELOG.md#unreleased)
7
7
  [![PyPi](https://badgen.net/badge/icon/python?icon=pypi&label)](https://pypi.org/project/hspylib-clitt)
8
8
  [![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com/yorevs/hspylib)
9
9
  [![Gitter](https://badgen.net/badge/icon/gitter?icon=gitter&label)](https://gitter.im/hspylib/community)
@@ -0,0 +1 @@
1
+ 0.9.49
@@ -25,4 +25,4 @@ class _Classpath(Classpath):
25
25
 
26
26
 
27
27
  # Instantiate the classpath singleton
28
- _Classpath()
28
+ assert _Classpath().INSTANCE is not None, "Failed to create Classpath instance"
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt
6
6
  """Package initialization."""
@@ -10,4 +10,4 @@ __all__ = [
10
10
  'core',
11
11
  'utils'
12
12
  ]
13
- __version__ = '0.9.47'
13
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.addons
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'appman',
10
10
  'widman'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.addons.appman
6
6
  """Package initialization."""
@@ -10,4 +10,4 @@ __all__ = [
10
10
  'appman_enums',
11
11
  'templates'
12
12
  ]
13
- __version__ = '0.9.47'
13
+ __version__ = '0.9.49'
@@ -13,7 +13,7 @@
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
15
  from clitt.addons.appman.appman_enums import AppExtension, AppType
16
- from clitt.core.tty.terminal import Terminal
16
+ from clitt.core.term.terminal import Terminal
17
17
  from clitt.core.tui.minput.input_validator import InputValidator
18
18
  from clitt.core.tui.minput.minput import MenuInput, minput
19
19
  from hspylib.core.enums.charset import Charset
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.addons.appman.templates
6
6
  """Package initialization."""
@@ -8,4 +8,4 @@
8
8
  __all__ = [
9
9
 
10
10
  ]
11
- __version__ = '0.9.47'
11
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.addons.widman
6
6
  """Package initialization."""
@@ -11,4 +11,4 @@ __all__ = [
11
11
  'widgets',
12
12
  'widman'
13
13
  ]
14
- __version__ = '0.9.47'
14
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.addons.widman.widgets
6
6
  """Package initialization."""
@@ -11,4 +11,4 @@ __all__ = [
11
11
  'widget_send_msg',
12
12
  'widget_time_calc'
13
13
  ]
14
- __version__ = '0.9.47'
14
+ __version__ = '0.9.49'
@@ -1,13 +1,13 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core
6
6
  """Package initialization."""
7
7
 
8
8
  __all__ = [
9
9
  'icons',
10
- 'tty',
10
+ 'term',
11
11
  'tui'
12
12
  ]
13
- __version__ = '0.9.47'
13
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.icons
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'emojis',
10
10
  'font_awesome'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.icons.emojis
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'emojis',
10
10
  'face_smiling'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.icons.font_awesome
6
6
  """Package initialization."""
@@ -14,4 +14,4 @@ __all__ = [
14
14
  'nav_icons',
15
15
  'widget_icons'
16
16
  ]
17
- __version__ = '0.9.47'
17
+ __version__ = '0.9.49'
@@ -0,0 +1,14 @@
1
+ # _*_ coding: utf-8 _*_
2
+ #
3
+ # hspylib-clitt v0.9.49
4
+ #
5
+ # Package: main.clitt.core.term
6
+ """Package initialization."""
7
+
8
+ __all__ = [
9
+ 'commons',
10
+ 'cursor',
11
+ 'screen',
12
+ 'terminal'
13
+ ]
14
+ __version__ = '0.9.49'
@@ -0,0 +1,63 @@
1
+ import logging as log
2
+ import re
3
+ import sys
4
+ import termios
5
+ import tty
6
+ from shutil import get_terminal_size
7
+ from typing import TypeVar, Tuple, Callable, Union
8
+
9
+ from hspylib.core.exception.exceptions import NotATerminalError
10
+ from hspylib.core.tools.commons import is_debugging
11
+ from hspylib.modules.cli.vt100.vt_100 import Vt100
12
+
13
+ DIMENSION = TypeVar("DIMENSION", bound=Tuple[int, int])
14
+
15
+ POSITION = TypeVar("POSITION", bound=Tuple[int, int])
16
+
17
+ CB_RESIZE = TypeVar("CB_RESIZE", bound=Callable[[None], None])
18
+
19
+ MOVE_DIRECTION = TypeVar("MOVE_DIRECTION", bound="Cursor.Direction")
20
+
21
+ ERASE_DIRECTION = TypeVar("ERASE_DIRECTION", bound=Union["Cursor.Direction", "Screen.Portion"])
22
+
23
+
24
+ def get_dimensions(fallback: Tuple[int, int] = (24, 80)) -> Tuple[int, int]:
25
+ """Retrieve the size of the terminal.
26
+ :return lines, columns
27
+ """
28
+ if not sys.stdout.isatty():
29
+ log.error(NotATerminalError("screen_size:: Requires a terminal (TTY)"))
30
+ return fallback
31
+ dim = get_terminal_size((fallback[1], fallback[0]))
32
+ return dim.lines, dim.columns
33
+
34
+
35
+ def get_cursor_position(fallback: Tuple[int, int] = (0, 0)) -> Tuple[int, int]:
36
+ """Get the terminal cursor position.
37
+ :return line, column
38
+ """
39
+ pos, buf = fallback, ""
40
+
41
+ if not sys.stdout.isatty():
42
+ log.error(NotATerminalError("get_cursor_position:: Requires a terminal (TTY)"))
43
+ return pos
44
+
45
+ if is_debugging():
46
+ return pos
47
+
48
+ stdin = sys.stdin.fileno() # Get the stdin file descriptor.
49
+ attrs = termios.tcgetattr(stdin) # Save terminal attributes.
50
+
51
+ try:
52
+ tty.setcbreak(stdin, termios.TCSANOW)
53
+ sys.stdout.write(Vt100.get_cursor_pos())
54
+ sys.stdout.flush()
55
+ while not buf or buf[-1] != "R":
56
+ buf += sys.stdin.read(1)
57
+ if matches := re.match(r"^\x1b\[(\d*);(\d*)R", buf): # If the response is 'Esc[r;cR'
58
+ groups = matches.groups()
59
+ pos = int(groups[0]), int(groups[1])
60
+ finally:
61
+ termios.tcsetattr(stdin, termios.TCSANOW, attrs) # Reset terminal attributes
62
+
63
+ return pos
@@ -9,13 +9,14 @@ from hspylib.modules.cli.vt100.vt_100 import Vt100
9
9
  from hspylib.modules.cli.vt100.vt_code import VtCode
10
10
  from hspylib.modules.cli.vt100.vt_color import VtColor
11
11
 
12
- from clitt.core.tty.terminal import Terminal
13
- from clitt.core.tty.tty_types import POSITION, MOVE_DIRECTION, ERASE_DIRECTION
12
+ from clitt.core.term.commons import POSITION, MOVE_DIRECTION, ERASE_DIRECTION, get_cursor_position
14
13
 
15
14
 
16
15
  class Cursor(metaclass=Singleton):
17
16
  """Provide a base class for the screen cursor."""
18
17
 
18
+ INSTANCE = None
19
+
19
20
  CURSOR_HOME = 1, 1
20
21
 
21
22
  class Direction(Enumeration):
@@ -28,7 +29,7 @@ class Cursor(metaclass=Singleton):
28
29
  # fmt: on
29
30
 
30
31
  def __init__(self):
31
- self._position: POSITION = Terminal.get_cursor_position() or self.CURSOR_HOME
32
+ self._position: POSITION = get_cursor_position() or self.CURSOR_HOME
32
33
  self._bottom: POSITION = self.CURSOR_HOME
33
34
  self._saved_attrs = self._position, self._bottom
34
35
 
@@ -91,7 +92,7 @@ class Cursor(metaclass=Singleton):
91
92
 
92
93
  def track(self) -> POSITION:
93
94
  """Track the cursor position."""
94
- self.position = Terminal.get_cursor_position() or self.position
95
+ self.position = get_cursor_position() or self.position
95
96
  return self.position
96
97
 
97
98
  def write(self, obj: Any, end: str = "") -> POSITION:
@@ -1,4 +1,3 @@
1
- import atexit
2
1
  import threading
3
2
  from threading import Timer
4
3
  from typing import Optional, List
@@ -7,9 +6,8 @@ from hspylib.core.enums.enumeration import Enumeration
7
6
  from hspylib.core.metaclass.singleton import Singleton
8
7
  from hspylib.core.tools.commons import sysout
9
8
 
10
- from clitt.core.tty.terminal import Terminal
11
- from clitt.core.tty.cursor import Cursor
12
- from clitt.core.tty.tty_types import DIMENSION, CB_RESIZE
9
+ from clitt.core.term.commons import DIMENSION, CB_RESIZE, get_dimensions
10
+ from clitt.core.term.cursor import Cursor
13
11
  from clitt.core.tui.tui_preferences import TUIPreferences
14
12
 
15
13
 
@@ -28,14 +26,12 @@ class Screen(metaclass=Singleton):
28
26
  # fmt: on
29
27
 
30
28
  def __init__(self):
31
- self._preferences: TUIPreferences = TUIPreferences.INSTANCE or TUIPreferences()
32
- self._dimension: DIMENSION = Terminal.get_dimensions()
33
- self._cursor: Cursor = Cursor()
29
+ self._preferences: TUIPreferences = TUIPreferences.INSTANCE
30
+ self._dimension: DIMENSION = get_dimensions()
31
+ self._cursor: Cursor = Cursor.INSTANCE or Cursor()
34
32
  self._resize_timer: Optional[Timer] = None
35
33
  self._cb_watchers: List[CB_RESIZE] = []
36
34
  self._alternate: bool = False
37
-
38
- atexit.register(Terminal.exit)
39
35
  self._resize_watcher()
40
36
 
41
37
  def __str__(self):
@@ -78,8 +74,8 @@ class Screen(metaclass=Singleton):
78
74
  self.cursor.track()
79
75
 
80
76
  def clear(self) -> None:
81
- """Clear the entire screen and move the cursor home."""
82
- Terminal.clear()
77
+ """Clear terminal and move the cursor to HOME position (0, 0)."""
78
+ sysout("%ED2%%HOM%", end="")
83
79
  self.cursor.home()
84
80
 
85
81
  def add_watcher(self, watcher: CB_RESIZE) -> None:
@@ -92,7 +88,7 @@ class Screen(metaclass=Singleton):
92
88
  """Add a watcher for screen resizes. If a resize is detected, the callback is called with the
93
89
  new dimension."""
94
90
  if self._cb_watchers and threading.main_thread().is_alive():
95
- dimension: DIMENSION = Terminal.get_dimensions()
91
+ dimension: DIMENSION = get_dimensions()
96
92
  self._resize_timer = Timer(self.RESIZE_WATCH_INTERVAL, self._resize_watcher)
97
93
  if dimension != self._dimension:
98
94
  list(map(lambda cb_w: cb_w(), self._cb_watchers))
@@ -12,42 +12,37 @@
12
12
 
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
+ import atexit
15
16
  import logging as log
16
17
  import os
17
18
  import platform
18
- import re
19
19
  import select
20
20
  import shlex
21
21
  import signal
22
22
  import subprocess
23
23
  import sys
24
- import termios
25
- import tty
26
- from abc import ABC
27
- from shutil import get_terminal_size
28
- from typing import Optional, Tuple
24
+ from typing import Optional, Tuple, Any
29
25
 
30
26
  from hspylib.core.enums.charset import Charset
31
27
  from hspylib.core.exception.exceptions import NotATerminalError
32
- from hspylib.core.tools.commons import is_debugging
28
+ from hspylib.core.metaclass.singleton import Singleton
33
29
  from hspylib.core.tools.commons import sysout
34
30
  from hspylib.modules.application.exit_status import ExitStatus
35
31
  from hspylib.modules.cli.keyboard import Keyboard
36
32
  from hspylib.modules.cli.vt100.vt_100 import Vt100
37
33
 
34
+ from clitt.core.term.screen import Screen
38
35
 
39
- class Terminal(ABC):
36
+
37
+ class Terminal(metaclass=Singleton):
40
38
  """Utility class to provide terminal features."""
41
39
 
40
+ INSTANCE = None
41
+
42
42
  @staticmethod
43
43
  def is_a_tty() -> bool:
44
44
  return sys.stdout.isatty()
45
45
 
46
- @staticmethod
47
- def clear() -> None:
48
- """Clear terminal and move the cursor to HOME position (0, 0)."""
49
- sysout("%ED2%%HOM%", end="")
50
-
51
46
  @staticmethod
52
47
  def shell_exec(cmd_line: str, **kwargs) -> Tuple[Optional[str], ExitStatus]:
53
48
  """Execute command with arguments and return it's run status."""
@@ -102,63 +97,12 @@ class Terminal(ABC):
102
97
  else:
103
98
  raise NotImplementedError(f"OS '{my_os}' is not supported")
104
99
 
105
- @classmethod
106
- def exit(
107
- cls,
108
- exit_msg: str | None = "") -> None:
109
- """Exit the application. Commonly called by hooked signals.
110
- :param exit_msg: the exiting message to be displayed.
111
- """
112
- cls.restore()
113
- sysout(f"%MOD(0)%" f"{exit_msg}")
114
-
115
100
  @classmethod
116
101
  def restore(cls) -> None:
117
102
  """Clear the terminal and restore default attributes [wrap,cursor,echo]."""
103
+ sysout("%MOD(0)%")
118
104
  cls.set_attributes(show_cursor=True, auto_wrap=True, enable_echo=True)
119
105
 
120
- @classmethod
121
- def get_dimensions(cls, fallback: Tuple[int, int] = (24, 80)) -> Tuple[int, int]:
122
- """Retrieve the size of the terminal.
123
- :return lines, columns
124
- """
125
- if not sys.stdout.isatty():
126
- log.error(NotATerminalError("screen_size:: Requires a terminal (TTY)"))
127
- return fallback
128
- dim = get_terminal_size((fallback[1], fallback[0]))
129
- return dim.lines, dim.columns
130
-
131
- @classmethod
132
- def get_cursor_position(cls, fallback: Tuple[int, int] = (0, 0)) -> Tuple[int, int]:
133
- """Get the terminal cursor position.
134
- :return line, column
135
- """
136
- pos, buf = fallback, ""
137
-
138
- if not cls.is_a_tty():
139
- log.error(NotATerminalError("get_cursor_position:: Requires a terminal (TTY)"))
140
- return pos
141
-
142
- if is_debugging():
143
- return pos
144
-
145
- stdin = sys.stdin.fileno() # Get the stdin file descriptor.
146
- attrs = termios.tcgetattr(stdin) # Save terminal attributes.
147
-
148
- try:
149
- tty.setcbreak(stdin, termios.TCSANOW)
150
- sys.stdout.write(Vt100.get_cursor_pos())
151
- sys.stdout.flush()
152
- while not buf or buf[-1] != "R":
153
- buf += sys.stdin.read(1)
154
- if matches := re.match(r"^\x1b\[(\d*);(\d*)R", buf): # If the response is 'Esc[r;cR'
155
- groups = matches.groups()
156
- pos = int(groups[0]), int(groups[1])
157
- finally:
158
- termios.tcsetattr(stdin, termios.TCSANOW, attrs) # Reset terminal attributes
159
-
160
- return pos
161
-
162
106
  @classmethod
163
107
  def set_enable_echo(cls, enabled: bool = True) -> None:
164
108
  """Enable echo in the terminal.
@@ -206,3 +150,18 @@ class Terminal(ABC):
206
150
  cls.set_auto_wrap(auto_wrap)
207
151
  if show_cursor is not None:
208
152
  cls.set_show_cursor(show_cursor)
153
+
154
+ def __init__(self):
155
+ self._screen = Screen.INSTANCE or Screen()
156
+ atexit.register(self.restore)
157
+
158
+ @property
159
+ def screen(self) -> Screen:
160
+ return self._screen
161
+
162
+ def echo(self, obj: Any, end=os.linesep) -> None:
163
+ """Write the string representation of the object to the screen."""
164
+ self.screen.cursor.write(obj, end=end)
165
+
166
+
167
+ assert Terminal().INSTANCE is not None, "Failed to create Terminal instance"
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui
6
6
  """Package initialization."""
@@ -16,4 +16,4 @@ __all__ = [
16
16
  'tui_component',
17
17
  'tui_preferences'
18
18
  ]
19
- __version__ = '0.9.47'
19
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.mchoose
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'mchoose',
10
10
  'menu_choose'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -13,8 +13,8 @@
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
15
  from clitt.core.icons.font_awesome.nav_icons import NavIcons
16
- from clitt.core.tty.cursor import Cursor
17
- from clitt.core.tty.screen import Screen
16
+ from clitt.core.term.cursor import Cursor
17
+ from clitt.core.term.screen import Screen
18
18
  from clitt.core.tui.tui_component import TUIComponent
19
19
  from functools import cached_property
20
20
  from hspylib.modules.cli.keyboard import Keyboard
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.mdashboard
6
6
  """Package initialization."""
@@ -11,4 +11,4 @@ __all__ = [
11
11
  'mdashboard',
12
12
  'menu_dashboard'
13
13
  ]
14
- __version__ = '0.9.47'
14
+ __version__ = '0.9.49'
@@ -13,8 +13,8 @@
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
15
  from clitt.core.icons.font_awesome.nav_icons import NavIcons
16
- from clitt.core.tty.cursor import Cursor
17
- from clitt.core.tty.screen import Screen
16
+ from clitt.core.term.cursor import Cursor
17
+ from clitt.core.term.screen import Screen
18
18
  from clitt.core.tui.mdashboard.dashboard_builder import DashboardBuilder
19
19
  from clitt.core.tui.mdashboard.dashboard_item import DashboardItem
20
20
  from clitt.core.tui.tui_component import TUIComponent
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.menu
6
6
  """Package initialization."""
@@ -13,4 +13,4 @@ __all__ = [
13
13
  'tui_menu_ui',
14
14
  'tui_menu_view'
15
15
  ]
16
- __version__ = '0.9.47'
16
+ __version__ = '0.9.49'
@@ -14,8 +14,8 @@
14
14
  """
15
15
 
16
16
  from clitt.core.icons.font_awesome.nav_icons import NavIcons
17
- from clitt.core.tty.cursor import Cursor
18
- from clitt.core.tty.screen import Screen
17
+ from clitt.core.term.cursor import Cursor
18
+ from clitt.core.term.screen import Screen
19
19
  from clitt.core.tui.menu.tui_menu import TUIMenu
20
20
  from clitt.core.tui.menu.tui_menu_ui import TUIMenuUi
21
21
  from functools import cached_property
@@ -12,8 +12,7 @@
12
12
 
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
- from clitt.core.tty.terminal import Terminal
16
- from clitt.core.tty.screen import Screen
15
+ from clitt.core.term.terminal import Terminal
17
16
  from clitt.core.tui.menu.tui_menu import TUIMenu
18
17
  from clitt.core.tui.tui_preferences import TUIPreferences
19
18
  from hspylib.core.metaclass.singleton import Singleton
@@ -28,9 +27,9 @@ class TUIMenuUi(metaclass=Singleton):
28
27
  APP_TITLE = "Main Menu"
29
28
 
30
29
  # fmt: off
31
- PREFS = TUIPreferences.INSTANCE or TUIPreferences()
30
+ PREFS = TUIPreferences.INSTANCE
32
31
 
33
- SCREEN = Screen.INSTANCE or Screen()
32
+ SCREEN = Terminal.INSTANCE.screen
34
33
 
35
34
  MENU_LINE = f"{'--' * PREFS.title_line_length}"
36
35
 
@@ -12,7 +12,7 @@
12
12
 
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
- from clitt.core.tty.cursor import Cursor
15
+ from clitt.core.term.cursor import Cursor
16
16
  from clitt.core.tui.menu.tui_menu import ON_TRIGGER_CB, TUIMenu
17
17
  from clitt.core.tui.menu.tui_menu_ui import TUIMenuUi
18
18
  from typing import Callable, Optional
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.minput
6
6
  """Package initialization."""
@@ -16,4 +16,4 @@ __all__ = [
16
16
  'minput',
17
17
  'minput_utils'
18
18
  ]
19
- __version__ = '0.9.47'
19
+ __version__ = '0.9.49'
@@ -23,8 +23,9 @@ from hspylib.modules.cli.keyboard import Keyboard
23
23
 
24
24
  from clitt.core.icons.font_awesome.form_icons import FormIcons
25
25
  from clitt.core.icons.font_awesome.nav_icons import NavIcons
26
- from clitt.core.tty.cursor import Cursor
27
- from clitt.core.tty.terminal import Terminal
26
+ from clitt.core.term.commons import get_cursor_position
27
+ from clitt.core.term.cursor import Cursor
28
+ from clitt.core.term.terminal import Terminal
28
29
  from clitt.core.tui.minput.form_builder import FormBuilder
29
30
  from clitt.core.tui.minput.form_field import FormField
30
31
  from clitt.core.tui.minput.input_type import InputType
@@ -267,7 +268,7 @@ class MenuInput(TUIComponent):
267
268
  :param field_index: the current form field index.
268
269
  :param field_size: the form field length.
269
270
  """
270
- if f_pos := Terminal.get_cursor_position() \
271
+ if f_pos := get_cursor_position() \
271
272
  if self.positions[field_index] == (0, 0) \
272
273
  else self.positions[field_index]:
273
274
  self.positions[field_index] = f_pos
@@ -17,7 +17,7 @@ from typing import Any, Optional, Tuple
17
17
 
18
18
  import re
19
19
 
20
- from clitt.core.tty.screen import Screen
20
+ from clitt.core.term.screen import Screen
21
21
 
22
22
  MASK_SYMBOLS = ["#", "@", "%", "*"]
23
23
 
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.mselect
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'menu_select',
10
10
  'mselect'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -13,8 +13,8 @@
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
15
  from clitt.core.icons.font_awesome.nav_icons import NavIcons
16
- from clitt.core.tty.cursor import Cursor
17
- from clitt.core.tty.screen import Screen
16
+ from clitt.core.term.cursor import Cursor
17
+ from clitt.core.term.screen import Screen
18
18
  from clitt.core.tui.tui_component import TUIComponent
19
19
  from functools import cached_property
20
20
  from hspylib.modules.cli.keyboard import Keyboard
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.core.tui.table
6
6
  """Package initialization."""
@@ -9,4 +9,4 @@ __all__ = [
9
9
  'table_enums',
10
10
  'table_renderer'
11
11
  ]
12
- __version__ = '0.9.47'
12
+ __version__ = '0.9.49'
@@ -12,16 +12,16 @@
12
12
 
13
13
  Copyright 2023, HsPyLib team
14
14
  """
15
- from clitt.core.tty.cursor import Cursor
16
- from clitt.core.tty.screen import Screen
17
- from clitt.core.tui.table.table_enums import TextAlignment, TextCase
15
+ import csv
16
+ import os
17
+ from typing import Any, Callable, Iterable, List
18
+
18
19
  from hspylib.core.preconditions import check_argument
19
20
  from hspylib.core.tools.commons import file_is_not_empty
20
21
  from hspylib.core.tools.text_tools import elide_text, ensure_endswith
21
- from typing import Any, Callable, Iterable, List
22
22
 
23
- import csv
24
- import os
23
+ from clitt.core.term.terminal import Terminal
24
+ from clitt.core.tui.table.table_enums import TextAlignment, TextCase
25
25
 
26
26
 
27
27
  class TableRenderer:
@@ -57,7 +57,7 @@ class TableRenderer:
57
57
  :param caption: table caption to be displayed.
58
58
  """
59
59
 
60
- self._screen = Screen.INSTANCE or Screen()
60
+ self._terminal = Terminal.INSTANCE
61
61
  self._headers = headers
62
62
  self._columns = range(len(self._headers))
63
63
  self._data = data if data else []
@@ -78,12 +78,8 @@ class TableRenderer:
78
78
  self.adjust_auto_fit()
79
79
 
80
80
  @property
81
- def screen(self) -> Screen:
82
- return self._screen
83
-
84
- @property
85
- def cursor(self) -> Cursor:
86
- return self.screen.cursor
81
+ def terminal(self) -> Terminal:
82
+ return self._terminal
87
83
 
88
84
  @property
89
85
  def data(self) -> Iterable:
@@ -195,7 +191,7 @@ class TableRenderer:
195
191
 
196
192
  def _display_data(self, data: Any) -> None:
197
193
  """Print out data into the screen."""
198
- self.cursor.writeln(data)
194
+ self.terminal.cursor.writeln(data)
199
195
 
200
196
  def _format_header_row(self) -> str:
201
197
  """Format the table header using the defined preferences."""
@@ -20,8 +20,9 @@ from hspylib.modules.application.application import Application
20
20
  from hspylib.modules.application.exit_status import ExitStatus
21
21
  from hspylib.modules.application.version import Version
22
22
 
23
- from clitt.core.tty.cursor import Cursor
24
- from clitt.core.tty.screen import Screen
23
+ from clitt.core.term.cursor import Cursor
24
+ from clitt.core.term.screen import Screen
25
+ from clitt.core.term.terminal import Terminal
25
26
 
26
27
 
27
28
  class TUIApplication(Application, metaclass=AbstractSingleton):
@@ -38,16 +39,20 @@ class TUIApplication(Application, metaclass=AbstractSingleton):
38
39
  log_dir: str = None):
39
40
 
40
41
  super().__init__(name, version, description, usage, epilog, resource_dir, log_dir)
41
- self._screen = Screen.INSTANCE or Screen()
42
+ self._terminal = Terminal.INSTANCE
42
43
  self._app_name = os.path.basename(sys.argv[0]) if name is None else name
43
44
 
45
+ @property
46
+ def terminal(self) -> Terminal():
47
+ return self._terminal
48
+
44
49
  @property
45
50
  def screen(self) -> Screen():
46
- return self._screen
51
+ return self.terminal.screen
47
52
 
48
53
  @property
49
54
  def cursor(self) -> Cursor:
50
- return self.screen.cursor
55
+ return self.terminal.cursor
51
56
 
52
57
  def _setup_arguments(self) -> None:
53
58
  pass
@@ -58,3 +63,4 @@ class TUIApplication(Application, metaclass=AbstractSingleton):
58
63
  def _cleanup(self) -> None:
59
64
  if self.screen.alternate and self._exit_code == ExitStatus.SUCCESS:
60
65
  self.screen.alternate = not self.screen.alternate
66
+ self.terminal.restore()
@@ -19,9 +19,9 @@ from hspylib.core.tools.text_tools import elide_text
19
19
  from hspylib.modules.cli.keyboard import Keyboard
20
20
 
21
21
  from clitt.core.icons.font_awesome.awesome import Awesome
22
- from clitt.core.tty.terminal import Terminal
23
- from clitt.core.tty.cursor import Cursor
24
- from clitt.core.tty.screen import Screen
22
+ from clitt.core.term.terminal import Terminal
23
+ from clitt.core.term.cursor import Cursor
24
+ from clitt.core.term.screen import Screen
25
25
  from clitt.core.tui.tui_preferences import TUIPreferences
26
26
 
27
27
  T = TypeVar("T", bound=Any)
@@ -34,7 +34,19 @@ class TUIComponent(ABC):
34
34
  self._re_render = True
35
35
  self._done = False
36
36
  self._title = title
37
- self._screen = Screen.INSTANCE or Screen()
37
+ self._terminal = Terminal.INSTANCE
38
+
39
+ @property
40
+ def terminal(self) -> Terminal:
41
+ return self._terminal
42
+
43
+ @property
44
+ def screen(self) -> Screen:
45
+ return self.terminal.screen
46
+
47
+ @property
48
+ def cursor(self) -> Cursor:
49
+ return self.terminal.screen.cursor
38
50
 
39
51
  @property
40
52
  def title(self) -> str:
@@ -42,28 +54,20 @@ class TUIComponent(ABC):
42
54
 
43
55
  @property
44
56
  def rows(self) -> int:
45
- return self._screen.lines
57
+ return self.screen.lines
46
58
 
47
59
  @property
48
60
  def columns(self) -> int:
49
- return self._screen.columns
61
+ return self.screen.columns
50
62
 
51
63
  @property
52
64
  def prefs(self) -> TUIPreferences:
53
65
  return self.screen.preferences
54
66
 
55
- @property
56
- def screen(self) -> Screen:
57
- return self._screen
58
-
59
- @property
60
- def cursor(self) -> Cursor:
61
- return self._screen.cursor
62
-
63
67
  def _prepare_render(self, auto_wrap: bool = False, show_cursor: bool = False) -> None:
64
68
  """Prepare the screen for renderization."""
65
69
 
66
- self._screen.add_watcher(self.invalidate)
70
+ self.screen.add_watcher(self.invalidate)
67
71
  Terminal.set_auto_wrap(auto_wrap)
68
72
  Terminal.set_show_cursor(show_cursor)
69
73
  self.screen.clear()
@@ -121,11 +125,11 @@ class TUIComponent(ABC):
121
125
 
122
126
  def write(self, obj: Any) -> None:
123
127
  """Write the string representation of the object to the screen."""
124
- self.cursor.write(obj)
128
+ self.terminal.echo(obj, end='')
125
129
 
126
130
  def writeln(self, obj: Any) -> None:
127
131
  """Write the string representation of the object to the screen, appending a new line."""
128
- self.cursor.writeln(obj)
132
+ self.terminal.echo(obj)
129
133
 
130
134
  def invalidate(self) -> None:
131
135
  """Invalidate current TUI renderization."""
@@ -145,3 +145,6 @@ class TUIPreferences(metaclass=Singleton):
145
145
  @property
146
146
  def unmarked(self) -> Awesome:
147
147
  return self._unmarked
148
+
149
+
150
+ assert TUIPreferences().INSTANCE is not None, "Failed to create TUIPreferences instance"
@@ -1,6 +1,6 @@
1
1
  # _*_ coding: utf-8 _*_
2
2
  #
3
- # hspylib-clitt v0.9.47
3
+ # hspylib-clitt v0.9.49
4
4
  #
5
5
  # Package: main.clitt.utils
6
6
  """Package initialization."""
@@ -8,4 +8,4 @@
8
8
  __all__ = [
9
9
  'git_utils'
10
10
  ]
11
- __version__ = '0.9.47'
11
+ __version__ = '0.9.49'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: hspylib-clitt
3
- Version: 0.9.47
3
+ Version: 0.9.49
4
4
  Summary: HsPyLib - CLI Terminal Tools
5
5
  Home-page: https://github.com/yorevs/hspylib
6
6
  Author: Hugo Saporetti Junior
@@ -30,7 +30,7 @@ Description-Content-Type: text/markdown
30
30
  ## Create professional CLI applications
31
31
 
32
32
  [![License](https://badgen.net/badge/license/MIT/gray)](LICENSE.md)
33
- [![Release](https://badgen.net/badge/release/v0.9.47/gray)](CHANGELOG.md#unreleased)
33
+ [![Release](https://badgen.net/badge/release/v0.9.49/gray)](CHANGELOG.md#unreleased)
34
34
  [![PyPi](https://badgen.net/badge/icon/python?icon=pypi&label)](https://pypi.org/project/hspylib-clitt)
35
35
  [![GitHub](https://badgen.net/badge/icon/github?icon=github&label)](https://github.com/yorevs/hspylib)
36
36
  [![Gitter](https://badgen.net/badge/icon/gitter?icon=gitter&label)](https://gitter.im/hspylib/community)
@@ -45,11 +45,11 @@ clitt/core/icons/font_awesome/dashboard_icons.py
45
45
  clitt/core/icons/font_awesome/form_icons.py
46
46
  clitt/core/icons/font_awesome/nav_icons.py
47
47
  clitt/core/icons/font_awesome/widget_icons.py
48
- clitt/core/tty/__init__.py
49
- clitt/core/tty/cursor.py
50
- clitt/core/tty/screen.py
51
- clitt/core/tty/terminal.py
52
- clitt/core/tty/tty_types.py
48
+ clitt/core/term/__init__.py
49
+ clitt/core/term/commons.py
50
+ clitt/core/term/cursor.py
51
+ clitt/core/term/screen.py
52
+ clitt/core/term/terminal.py
53
53
  clitt/core/tui/__init__.py
54
54
  clitt/core/tui/tui_application.py
55
55
  clitt/core/tui/tui_component.py
@@ -1 +0,0 @@
1
- 0.9.47
@@ -1,14 +0,0 @@
1
- # _*_ coding: utf-8 _*_
2
- #
3
- # hspylib-clitt v0.9.47
4
- #
5
- # Package: main.clitt.core.tty
6
- """Package initialization."""
7
-
8
- __all__ = [
9
- 'cursor',
10
- 'screen',
11
- 'terminal',
12
- 'tty_types'
13
- ]
14
- __version__ = '0.9.47'
@@ -1,11 +0,0 @@
1
- from typing import TypeVar, Tuple, Callable, Union
2
-
3
- DIMENSION = TypeVar("DIMENSION", bound=Tuple[int, int])
4
-
5
- POSITION = TypeVar("POSITION", bound=Tuple[int, int])
6
-
7
- CB_RESIZE = TypeVar("CB_RESIZE", bound=Callable[[None], None])
8
-
9
- MOVE_DIRECTION = TypeVar("MOVE_DIRECTION", bound="Cursor.Direction")
10
-
11
- ERASE_DIRECTION = TypeVar("ERASE_DIRECTION", bound=Union["Cursor.Direction", "Screen.Portion"])
File without changes
File without changes