hspylib-clitt 0.9.120__py3-none-any.whl → 0.9.121__py3-none-any.whl

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 (266) hide show
  1. clitt/.version +1 -1
  2. clitt/__init__.py +3 -3
  3. clitt/addons/__init__.py +3 -3
  4. clitt/addons/appman/__init__.py +3 -3
  5. clitt/addons/appman/templates/__init__.py +3 -3
  6. clitt/addons/widman/__init__.py +3 -3
  7. clitt/addons/widman/widgets/__init__.py +3 -3
  8. clitt/core/__init__.py +3 -3
  9. clitt/core/exception/__init__.py +3 -3
  10. clitt/core/icons/__init__.py +3 -3
  11. clitt/core/icons/emojis/__init__.py +3 -3
  12. clitt/core/icons/font_awesome/__init__.py +3 -3
  13. clitt/core/term/__init__.py +3 -3
  14. clitt/core/tui/__init__.py +3 -3
  15. clitt/core/tui/line_input/__init__.py +3 -3
  16. clitt/core/tui/line_input/keyboard_input.py +70 -63
  17. clitt/core/tui/mchoose/__init__.py +3 -3
  18. clitt/core/tui/mdashboard/__init__.py +3 -3
  19. clitt/core/tui/menu/__init__.py +3 -3
  20. clitt/core/tui/minput/__init__.py +3 -3
  21. clitt/core/tui/minput/menu_input.py +7 -15
  22. clitt/core/tui/mselect/__init__.py +3 -3
  23. clitt/core/tui/table/__init__.py +3 -3
  24. clitt/utils/__init__.py +3 -3
  25. {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/METADATA +2 -2
  26. hspylib_clitt-0.9.121.dist-info/RECORD +97 -0
  27. {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/top_level.txt +0 -1
  28. build/lib/build/lib/build/lib/clitt/__classpath__.py +0 -28
  29. build/lib/build/lib/build/lib/clitt/__init__.py +0 -13
  30. build/lib/build/lib/build/lib/clitt/__main__.py +0 -139
  31. build/lib/build/lib/build/lib/clitt/addons/__init__.py +0 -12
  32. build/lib/build/lib/build/lib/clitt/addons/appman/__init__.py +0 -13
  33. build/lib/build/lib/build/lib/clitt/addons/appman/appman.py +0 -305
  34. build/lib/build/lib/build/lib/clitt/addons/appman/appman_enums.py +0 -39
  35. build/lib/build/lib/build/lib/clitt/addons/appman/templates/__init__.py +0 -11
  36. build/lib/build/lib/build/lib/clitt/addons/widman/__init__.py +0 -14
  37. build/lib/build/lib/build/lib/clitt/addons/widman/widget.py +0 -70
  38. build/lib/build/lib/build/lib/clitt/addons/widman/widget_entry.py +0 -54
  39. build/lib/build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
  40. build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
  41. build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
  42. build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
  43. build/lib/build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
  44. build/lib/build/lib/build/lib/clitt/addons/widman/widman.py +0 -123
  45. build/lib/build/lib/build/lib/clitt/core/__init__.py +0 -15
  46. build/lib/build/lib/build/lib/clitt/core/exception/__init__.py +0 -11
  47. build/lib/build/lib/build/lib/clitt/core/exception/exceptions.py +0 -19
  48. build/lib/build/lib/build/lib/clitt/core/icons/__init__.py +0 -12
  49. build/lib/build/lib/build/lib/clitt/core/icons/emojis/__init__.py +0 -12
  50. build/lib/build/lib/build/lib/clitt/core/icons/emojis/emojis.py +0 -41
  51. build/lib/build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
  52. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
  53. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
  54. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
  55. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
  56. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
  57. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
  58. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
  59. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
  60. build/lib/build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
  61. build/lib/build/lib/build/lib/clitt/core/preferences.py +0 -87
  62. build/lib/build/lib/build/lib/clitt/core/term/__init__.py +0 -14
  63. build/lib/build/lib/build/lib/clitt/core/term/commons.py +0 -106
  64. build/lib/build/lib/build/lib/clitt/core/term/cursor.py +0 -174
  65. build/lib/build/lib/build/lib/clitt/core/term/screen.py +0 -106
  66. build/lib/build/lib/build/lib/clitt/core/term/terminal.py +0 -202
  67. build/lib/build/lib/build/lib/clitt/core/tui/__init__.py +0 -20
  68. build/lib/build/lib/build/lib/clitt/core/tui/line_input/__init__.py +0 -12
  69. build/lib/build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
  70. build/lib/build/lib/build/lib/clitt/core/tui/line_input/line_input.py +0 -31
  71. build/lib/build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
  72. build/lib/build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
  73. build/lib/build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
  74. build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
  75. build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
  76. build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
  77. build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
  78. build/lib/build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
  79. build/lib/build/lib/build/lib/clitt/core/tui/menu/__init__.py +0 -16
  80. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
  81. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
  82. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
  83. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
  84. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
  85. build/lib/build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
  86. build/lib/build/lib/build/lib/clitt/core/tui/minput/__init__.py +0 -19
  87. build/lib/build/lib/build/lib/clitt/core/tui/minput/access_type.py +0 -26
  88. build/lib/build/lib/build/lib/clitt/core/tui/minput/field_builder.py +0 -117
  89. build/lib/build/lib/build/lib/clitt/core/tui/minput/form_builder.py +0 -72
  90. build/lib/build/lib/build/lib/clitt/core/tui/minput/form_field.py +0 -180
  91. build/lib/build/lib/build/lib/clitt/core/tui/minput/input_type.py +0 -30
  92. build/lib/build/lib/build/lib/clitt/core/tui/minput/input_validator.py +0 -98
  93. build/lib/build/lib/build/lib/clitt/core/tui/minput/menu_input.py +0 -292
  94. build/lib/build/lib/build/lib/clitt/core/tui/minput/minput.py +0 -44
  95. build/lib/build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
  96. build/lib/build/lib/build/lib/clitt/core/tui/mselect/__init__.py +0 -12
  97. build/lib/build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
  98. build/lib/build/lib/build/lib/clitt/core/tui/mselect/mselect.py +0 -36
  99. build/lib/build/lib/build/lib/clitt/core/tui/table/__init__.py +0 -12
  100. build/lib/build/lib/build/lib/clitt/core/tui/table/table_enums.py +0 -47
  101. build/lib/build/lib/build/lib/clitt/core/tui/table/table_renderer.py +0 -339
  102. build/lib/build/lib/build/lib/clitt/core/tui/tui_application.py +0 -52
  103. build/lib/build/lib/build/lib/clitt/core/tui/tui_component.py +0 -154
  104. build/lib/build/lib/build/lib/clitt/core/tui/tui_preferences.py +0 -103
  105. build/lib/build/lib/build/lib/clitt/utils/__init__.py +0 -11
  106. build/lib/build/lib/build/lib/clitt/utils/git_utils.py +0 -66
  107. build/lib/build/lib/clitt/__classpath__.py +0 -28
  108. build/lib/build/lib/clitt/__init__.py +0 -13
  109. build/lib/build/lib/clitt/__main__.py +0 -139
  110. build/lib/build/lib/clitt/addons/__init__.py +0 -12
  111. build/lib/build/lib/clitt/addons/appman/__init__.py +0 -13
  112. build/lib/build/lib/clitt/addons/appman/appman.py +0 -305
  113. build/lib/build/lib/clitt/addons/appman/appman_enums.py +0 -39
  114. build/lib/build/lib/clitt/addons/appman/templates/__init__.py +0 -11
  115. build/lib/build/lib/clitt/addons/widman/__init__.py +0 -14
  116. build/lib/build/lib/clitt/addons/widman/widget.py +0 -70
  117. build/lib/build/lib/clitt/addons/widman/widget_entry.py +0 -54
  118. build/lib/build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
  119. build/lib/build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
  120. build/lib/build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
  121. build/lib/build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
  122. build/lib/build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
  123. build/lib/build/lib/clitt/addons/widman/widman.py +0 -123
  124. build/lib/build/lib/clitt/core/__init__.py +0 -15
  125. build/lib/build/lib/clitt/core/exception/__init__.py +0 -11
  126. build/lib/build/lib/clitt/core/exception/exceptions.py +0 -19
  127. build/lib/build/lib/clitt/core/icons/__init__.py +0 -12
  128. build/lib/build/lib/clitt/core/icons/emojis/__init__.py +0 -12
  129. build/lib/build/lib/clitt/core/icons/emojis/emojis.py +0 -41
  130. build/lib/build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
  131. build/lib/build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
  132. build/lib/build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
  133. build/lib/build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
  134. build/lib/build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
  135. build/lib/build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
  136. build/lib/build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
  137. build/lib/build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
  138. build/lib/build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
  139. build/lib/build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
  140. build/lib/build/lib/clitt/core/preferences.py +0 -87
  141. build/lib/build/lib/clitt/core/term/__init__.py +0 -14
  142. build/lib/build/lib/clitt/core/term/commons.py +0 -106
  143. build/lib/build/lib/clitt/core/term/cursor.py +0 -174
  144. build/lib/build/lib/clitt/core/term/screen.py +0 -106
  145. build/lib/build/lib/clitt/core/term/terminal.py +0 -202
  146. build/lib/build/lib/clitt/core/tui/__init__.py +0 -20
  147. build/lib/build/lib/clitt/core/tui/line_input/__init__.py +0 -12
  148. build/lib/build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
  149. build/lib/build/lib/clitt/core/tui/line_input/line_input.py +0 -31
  150. build/lib/build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
  151. build/lib/build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
  152. build/lib/build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
  153. build/lib/build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
  154. build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
  155. build/lib/build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
  156. build/lib/build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
  157. build/lib/build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
  158. build/lib/build/lib/clitt/core/tui/menu/__init__.py +0 -16
  159. build/lib/build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
  160. build/lib/build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
  161. build/lib/build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
  162. build/lib/build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
  163. build/lib/build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
  164. build/lib/build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
  165. build/lib/build/lib/clitt/core/tui/minput/__init__.py +0 -19
  166. build/lib/build/lib/clitt/core/tui/minput/access_type.py +0 -26
  167. build/lib/build/lib/clitt/core/tui/minput/field_builder.py +0 -117
  168. build/lib/build/lib/clitt/core/tui/minput/form_builder.py +0 -72
  169. build/lib/build/lib/clitt/core/tui/minput/form_field.py +0 -180
  170. build/lib/build/lib/clitt/core/tui/minput/input_type.py +0 -30
  171. build/lib/build/lib/clitt/core/tui/minput/input_validator.py +0 -98
  172. build/lib/build/lib/clitt/core/tui/minput/menu_input.py +0 -292
  173. build/lib/build/lib/clitt/core/tui/minput/minput.py +0 -44
  174. build/lib/build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
  175. build/lib/build/lib/clitt/core/tui/mselect/__init__.py +0 -12
  176. build/lib/build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
  177. build/lib/build/lib/clitt/core/tui/mselect/mselect.py +0 -36
  178. build/lib/build/lib/clitt/core/tui/table/__init__.py +0 -12
  179. build/lib/build/lib/clitt/core/tui/table/table_enums.py +0 -47
  180. build/lib/build/lib/clitt/core/tui/table/table_renderer.py +0 -339
  181. build/lib/build/lib/clitt/core/tui/tui_application.py +0 -52
  182. build/lib/build/lib/clitt/core/tui/tui_component.py +0 -154
  183. build/lib/build/lib/clitt/core/tui/tui_preferences.py +0 -103
  184. build/lib/build/lib/clitt/utils/__init__.py +0 -11
  185. build/lib/build/lib/clitt/utils/git_utils.py +0 -66
  186. build/lib/clitt/__classpath__.py +0 -28
  187. build/lib/clitt/__init__.py +0 -13
  188. build/lib/clitt/__main__.py +0 -139
  189. build/lib/clitt/addons/__init__.py +0 -12
  190. build/lib/clitt/addons/appman/__init__.py +0 -13
  191. build/lib/clitt/addons/appman/appman.py +0 -305
  192. build/lib/clitt/addons/appman/appman_enums.py +0 -39
  193. build/lib/clitt/addons/appman/templates/__init__.py +0 -11
  194. build/lib/clitt/addons/widman/__init__.py +0 -14
  195. build/lib/clitt/addons/widman/widget.py +0 -70
  196. build/lib/clitt/addons/widman/widget_entry.py +0 -54
  197. build/lib/clitt/addons/widman/widgets/__init__.py +0 -14
  198. build/lib/clitt/addons/widman/widgets/widget_free.py +0 -110
  199. build/lib/clitt/addons/widman/widgets/widget_punch.py +0 -246
  200. build/lib/clitt/addons/widman/widgets/widget_send_msg.py +0 -272
  201. build/lib/clitt/addons/widman/widgets/widget_time_calc.py +0 -146
  202. build/lib/clitt/addons/widman/widman.py +0 -123
  203. build/lib/clitt/core/__init__.py +0 -15
  204. build/lib/clitt/core/exception/__init__.py +0 -11
  205. build/lib/clitt/core/exception/exceptions.py +0 -19
  206. build/lib/clitt/core/icons/__init__.py +0 -12
  207. build/lib/clitt/core/icons/emojis/__init__.py +0 -12
  208. build/lib/clitt/core/icons/emojis/emojis.py +0 -41
  209. build/lib/clitt/core/icons/emojis/face_smiling.py +0 -40
  210. build/lib/clitt/core/icons/font_awesome/__init__.py +0 -18
  211. build/lib/clitt/core/icons/font_awesome/app_icons.py +0 -55
  212. build/lib/clitt/core/icons/font_awesome/awesome.py +0 -76
  213. build/lib/clitt/core/icons/font_awesome/dashboard_icons.py +0 -93
  214. build/lib/clitt/core/icons/font_awesome/form_icons.py +0 -69
  215. build/lib/clitt/core/icons/font_awesome/game_icons.py +0 -59
  216. build/lib/clitt/core/icons/font_awesome/nav_icons.py +0 -42
  217. build/lib/clitt/core/icons/font_awesome/trickplay_icons.py +0 -39
  218. build/lib/clitt/core/icons/font_awesome/widget_icons.py +0 -37
  219. build/lib/clitt/core/preferences.py +0 -87
  220. build/lib/clitt/core/term/__init__.py +0 -14
  221. build/lib/clitt/core/term/commons.py +0 -106
  222. build/lib/clitt/core/term/cursor.py +0 -174
  223. build/lib/clitt/core/term/screen.py +0 -106
  224. build/lib/clitt/core/term/terminal.py +0 -202
  225. build/lib/clitt/core/tui/__init__.py +0 -20
  226. build/lib/clitt/core/tui/line_input/__init__.py +0 -12
  227. build/lib/clitt/core/tui/line_input/keyboard_input.py +0 -229
  228. build/lib/clitt/core/tui/line_input/line_input.py +0 -31
  229. build/lib/clitt/core/tui/mchoose/__init__.py +0 -12
  230. build/lib/clitt/core/tui/mchoose/mchoose.py +0 -43
  231. build/lib/clitt/core/tui/mchoose/menu_choose.py +0 -192
  232. build/lib/clitt/core/tui/mdashboard/__init__.py +0 -14
  233. build/lib/clitt/core/tui/mdashboard/dashboard_builder.py +0 -54
  234. build/lib/clitt/core/tui/mdashboard/dashboard_item.py +0 -31
  235. build/lib/clitt/core/tui/mdashboard/mdashboard.py +0 -26
  236. build/lib/clitt/core/tui/mdashboard/menu_dashboard.py +0 -148
  237. build/lib/clitt/core/tui/menu/__init__.py +0 -16
  238. build/lib/clitt/core/tui/menu/tui_menu.py +0 -111
  239. build/lib/clitt/core/tui/menu/tui_menu_action.py +0 -47
  240. build/lib/clitt/core/tui/menu/tui_menu_factory.py +0 -117
  241. build/lib/clitt/core/tui/menu/tui_menu_item.py +0 -196
  242. build/lib/clitt/core/tui/menu/tui_menu_ui.py +0 -98
  243. build/lib/clitt/core/tui/menu/tui_menu_view.py +0 -57
  244. build/lib/clitt/core/tui/minput/__init__.py +0 -19
  245. build/lib/clitt/core/tui/minput/access_type.py +0 -26
  246. build/lib/clitt/core/tui/minput/field_builder.py +0 -117
  247. build/lib/clitt/core/tui/minput/form_builder.py +0 -72
  248. build/lib/clitt/core/tui/minput/form_field.py +0 -180
  249. build/lib/clitt/core/tui/minput/input_type.py +0 -30
  250. build/lib/clitt/core/tui/minput/input_validator.py +0 -98
  251. build/lib/clitt/core/tui/minput/menu_input.py +0 -292
  252. build/lib/clitt/core/tui/minput/minput.py +0 -44
  253. build/lib/clitt/core/tui/minput/minput_utils.py +0 -156
  254. build/lib/clitt/core/tui/mselect/__init__.py +0 -12
  255. build/lib/clitt/core/tui/mselect/menu_select.py +0 -170
  256. build/lib/clitt/core/tui/mselect/mselect.py +0 -36
  257. build/lib/clitt/core/tui/table/__init__.py +0 -12
  258. build/lib/clitt/core/tui/table/table_enums.py +0 -47
  259. build/lib/clitt/core/tui/table/table_renderer.py +0 -339
  260. build/lib/clitt/core/tui/tui_application.py +0 -52
  261. build/lib/clitt/core/tui/tui_component.py +0 -154
  262. build/lib/clitt/core/tui/tui_preferences.py +0 -103
  263. build/lib/clitt/utils/__init__.py +0 -11
  264. build/lib/clitt/utils/git_utils.py +0 -66
  265. hspylib_clitt-0.9.120.dist-info/RECORD +0 -334
  266. {hspylib_clitt-0.9.120.dist-info → hspylib_clitt-0.9.121.dist-info}/WHEEL +0 -0
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @project: hspylib-clitt
6
- @package: hspylib-clitt.main.clitt.core.term
7
- @file: commons.py
8
- @created: Wed, 20 Mar 2024
9
- @author: "<B>H</B>ugo <B>S</B>aporetti <B>J</B>unior")"
10
- @site: "https://github.com/yorevs/hspylib")
11
- @license: MIT - Please refer to <https://opensource.org/licenses/MIT>
12
-
13
- Copyright 2024, HSPyLib team
14
- """
15
-
16
- import re
17
- import sys
18
- import termios
19
- import tty
20
- from shutil import get_terminal_size
21
- from typing import Callable, Tuple, TypeAlias, Union
22
-
23
- from hspylib.core.enums.enumeration import Enumeration
24
- from hspylib.core.tools.commons import is_debugging
25
- from hspylib.modules.cli.vt100.vt_100 import Vt100
26
-
27
- # fmt: off
28
- Dimension : TypeAlias = Tuple[int, int]
29
- Position : TypeAlias = Tuple[int, int]
30
- Resize_Cb : TypeAlias = Callable[[], None]
31
- MoveDirection : TypeAlias = "Direction"
32
- EraseDirection : TypeAlias = Union["Direction", "Portion"]
33
- # fmt: on
34
-
35
-
36
- def is_a_tty() -> bool:
37
- """Checks whether we are under a tty environment."""
38
- try:
39
- return sys.stdout.isatty() and sys.stdin.isatty()
40
- except ValueError:
41
- return sys.stdout.isatty()
42
-
43
-
44
- class Direction(Enumeration):
45
- """Provide a base class for the cursor direction."""
46
-
47
- # fmt: off
48
- UP = '%ED1%', '%CUU({n})%' # Cursor up (line)
49
- RIGHT = '%EL0%', '%CUF({n})%' # Cursor right (forward)
50
- DOWN = '%ED0%', '%CUD({n})%' # Cursor down (line)
51
- LEFT = '%EL1%', '%CUB({n})%' # Cursor left (backward)
52
- # fmt: on
53
-
54
-
55
- class Portion(Enumeration):
56
- """Provide a base class for the portions of the screen."""
57
-
58
- # fmt: off
59
- SCREEN = '%ED2%', '' # Entire screen (screen)
60
- LINE = '%EL2%', '' # Entire line (line)
61
- # fmt: on
62
-
63
-
64
- def get_dimensions(fallback: Tuple[int, int] = (24, 80)) -> Tuple[int, int]:
65
- """Retrieve the size of the terminal.
66
- :return lines, columns
67
- """
68
- if not is_a_tty():
69
- return fallback
70
- dim = get_terminal_size((fallback[1], fallback[0]))
71
- return dim.lines, dim.columns
72
-
73
-
74
- def get_cursor_position(fallback: Tuple[int, int] = (0, 0)) -> Tuple[int, int]:
75
- """Get the terminal cursor position.
76
- :return line, column
77
- """
78
- pos = fallback
79
-
80
- if is_debugging():
81
- return pos
82
-
83
- if not is_a_tty():
84
- return pos
85
-
86
- buf, re_query_resp = "", r"^\x1b\[(\d*);(\d*)R"
87
- stdin, attrs = None, None
88
-
89
- try:
90
- stdin = sys.stdin.fileno() # Get the stdin file descriptor.
91
- attrs = termios.tcgetattr(stdin) # Save terminal attributes.
92
- tty.setcbreak(stdin, termios.TCSANOW)
93
- sys.stdout.write(Vt100.get_cursor_pos())
94
- sys.stdout.flush()
95
- while not buf or buf[-1] != "R":
96
- buf += sys.stdin.read(1)
97
- if matches := re.match(re_query_resp, buf): # If the response is 'Esc[r;cR'
98
- groups = matches.groups()
99
- pos = int(groups[0]), int(groups[1])
100
- except termios.error:
101
- pass
102
- finally:
103
- if stdin and attrs:
104
- termios.tcsetattr(stdin, termios.TCSANOW, attrs) # Reset terminal attributes
105
-
106
- return pos
@@ -1,174 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @project: hspylib-clitt
6
- @package: hspylib-clitt.main.clitt.core.term
7
- @file: cursor.py
8
- @created: Wed, 20 Mar 2024
9
- @author: "<B>H</B>ugo <B>S</B>aporetti <B>J</B>unior")"
10
- @site: "https://github.com/yorevs/hspylib")
11
- @license: MIT - Please refer to <https://opensource.org/licenses/MIT>
12
-
13
- Copyright 2024, HSPyLib team
14
- """
15
-
16
- from clitt.core.term.commons import Direction, EraseDirection, get_cursor_position, MoveDirection, Portion, Position
17
- from hspylib.core.metaclass.singleton import Singleton
18
- from hspylib.core.tools.commons import sysout
19
- from hspylib.core.tools.text_tools import last_index_of
20
- from hspylib.modules.cli.vt100.vt_100 import Vt100
21
- from hspylib.modules.cli.vt100.vt_code import VtCode
22
- from hspylib.modules.cli.vt100.vt_color import VtColor
23
- from typing import Any
24
-
25
- import os
26
-
27
-
28
- class Cursor(metaclass=Singleton):
29
- """Provide a base class for the screen cursor."""
30
-
31
- INSTANCE = None
32
-
33
- CURSOR_HOME = 1, 1
34
-
35
- def __init__(self):
36
- self._position: Position = get_cursor_position() or self.CURSOR_HOME
37
- self._bottom: Position = self.CURSOR_HOME
38
- self._saved_attrs = self._position, self._bottom
39
-
40
- def __str__(self):
41
- return f"({', '.join(list(map(str, self._position)))})"
42
-
43
- def __repr__(self):
44
- return str(self)
45
-
46
- @property
47
- def position(self) -> Position:
48
- return self._position
49
-
50
- @position.setter
51
- def position(self, new_position: Position) -> None:
52
- self._bottom = (new_position[0], new_position[1]) if new_position >= self._bottom else self._bottom
53
- self._position = new_position
54
-
55
- @property
56
- def bottom(self) -> Position:
57
- return self._bottom
58
-
59
- def home(self) -> None:
60
- """Move the cursor to home position.
61
- :return None
62
- """
63
- self.move_to(self.CURSOR_HOME[0], self.CURSOR_HOME[1])
64
-
65
- def end(self) -> None:
66
- """Move the cursor to the bottom most position on the screen.
67
- :return None
68
- """
69
- self.move_to(self.bottom[0], self.bottom[1])
70
-
71
- def move_to(self, row: int = None, column: int = None) -> Position:
72
- """Move the cursor to the specified position.
73
- :param row the specified row to move.
74
- :param column the specified column to move.
75
- :return the cursor position after moving.
76
- """
77
- row_pos = max(self.CURSOR_HOME[0], row if row is not None else self.position[0])
78
- col_pos = max(self.CURSOR_HOME[1], column if column is not None else self.position[1])
79
- sysout(f"%CUP({row_pos};{col_pos})%", end="")
80
- self.position = row_pos, col_pos
81
- return self.position
82
-
83
- def move(self, amount: int, direction: MoveDirection) -> Position:
84
- """Move the cursor towards the specified direction.
85
- :param amount the amount of columns to move.
86
- :param direction the direction to move.
87
- :return the cursor position after moving.
88
- """
89
- if amount > 0:
90
- sysout(direction.value[1].format(n=amount), end="")
91
- row_pos, col_pos = self.position
92
- match direction:
93
- case Direction.UP:
94
- row_pos -= max(0, amount)
95
- case Direction.DOWN:
96
- row_pos += max(0, amount)
97
- case Direction.LEFT:
98
- col_pos -= max(0, amount)
99
- case Direction.RIGHT:
100
- col_pos += max(0, amount)
101
- self.position = row_pos, col_pos
102
- return self.position
103
-
104
- def erase(self, direction: EraseDirection) -> Position:
105
- """Erase the screen following the specified direction.
106
- Note: It does not move the cursor along the way.
107
- :param direction the direction to erase the screen.
108
- :return the cursor position after erasing.
109
- """
110
- sysout(direction.value[0], end="")
111
- return self.position
112
-
113
- def erase_line(self) -> Position:
114
- """Erase the previous line of the screen."""
115
- row_pos, col_pos = self.position
116
- self.move(1, Direction.UP)
117
- self.erase(Portion.LINE)
118
- self.move(col_pos, Direction.LEFT)
119
- self.position = row_pos, 0
120
- return self.position
121
-
122
- def track(self) -> Position:
123
- """Track the cursor position.
124
- :return the tracked cursor position.
125
- """
126
- self.position = get_cursor_position() or self.position
127
- return self.position
128
-
129
- def write(self, obj: Any, end: str = "") -> Position:
130
- """Write the string representation of the object to the screen.
131
- :param obj the object to be written.
132
- :param end string appended after the last value, default a newline.
133
- :return the cursor position after writing.
134
- """
135
- sysout(obj, end=end)
136
- text = (str(obj) + end).replace("%EOL%", os.linesep)
137
- text = VtColor.strip_colors(VtCode.strip_codes(text))
138
- text_offset = len(text[max(0, last_index_of(text, os.linesep)) :])
139
- self.position = self.position[0] + text.count(os.linesep), text_offset + (
140
- self.position[1] if text.count(os.linesep) == 0 else 0
141
- )
142
- return self.position
143
-
144
- def writeln(self, obj: Any) -> Position:
145
- """Write the string representation of the object to the screen, appending a new line.
146
- :param obj the object to be written.
147
- :return the cursor position after writing.
148
- """
149
- return self.write(obj, end=os.linesep)
150
-
151
- def save(self) -> Position:
152
- """Save the current cursor position and attributes.
153
- :return the actual cursor position.
154
- """
155
- sysout(Vt100.save_cursor(), end="")
156
- self._saved_attrs = self._position, self._bottom
157
- return self.position
158
-
159
- def restore(self) -> Position:
160
- """Restore the saved cursor position and attributes.
161
- :return the cursor position after restoration.
162
- """
163
- sysout(Vt100.restore_cursor(), end="")
164
- self._position = self._saved_attrs[0]
165
- self._bottom = self._saved_attrs[1]
166
- return self.position
167
-
168
- def reset_mode(self, end="") -> Position:
169
- """Reset cursor modifiers."""
170
- sysout(Vt100.mode(0), end=end)
171
- return self.position
172
-
173
-
174
- assert (cursor := Cursor().INSTANCE) is not None, "Failed to create Cursor instance"
@@ -1,106 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @project: hspylib-clitt
6
- @package: hspylib-clitt.main.clitt.core.term
7
- @file: screen.py
8
- @created: Wed, 20 Mar 2024
9
- @author: "<B>H</B>ugo <B>S</B>aporetti <B>J</B>unior")"
10
- @site: "https://github.com/yorevs/hspylib")
11
- @license: MIT - Please refer to <https://opensource.org/licenses/MIT>
12
-
13
- Copyright 2024, HSPyLib team
14
- """
15
-
16
- from clitt.core.term.commons import Dimension, get_dimensions, Portion, Resize_Cb
17
- from clitt.core.term.cursor import Cursor
18
- from clitt.core.tui.tui_preferences import TUIPreferences
19
- from hspylib.core.metaclass.singleton import Singleton
20
- from hspylib.core.tools.commons import sysout
21
- from threading import Timer
22
- from typing import List, Optional
23
-
24
- import threading
25
-
26
-
27
- class Screen(metaclass=Singleton):
28
- """Provide a base class for terminal UI components."""
29
-
30
- INSTANCE = None
31
-
32
- RESIZE_WATCH_INTERVAL = 0.5
33
-
34
- def __init__(self):
35
- self._preferences: TUIPreferences = TUIPreferences.INSTANCE
36
- self._dimension: Dimension = get_dimensions()
37
- self._cursor: Cursor = Cursor.INSTANCE or Cursor()
38
- self._resize_timer: Optional[Timer] = None
39
- self._cb_watchers: List[Resize_Cb] = []
40
- self._alternate: bool = False
41
- self._resize_watcher()
42
-
43
- def __str__(self):
44
- return f"Terminal.Screen(rows={self.lines}, columns={self.columns}, cursor={self.cursor})"
45
-
46
- def __repr__(self):
47
- return str(self)
48
-
49
- @property
50
- def preferences(self) -> TUIPreferences:
51
- return self._preferences
52
-
53
- @property
54
- def dimension(self) -> Dimension:
55
- return self._dimension
56
-
57
- @property
58
- def lines(self) -> int:
59
- return self._dimension[0]
60
-
61
- @property
62
- def columns(self) -> int:
63
- return self._dimension[1]
64
-
65
- @property
66
- def cursor(self) -> Cursor:
67
- return self._cursor
68
-
69
- @property
70
- def alternate(self) -> bool:
71
- return self._alternate
72
-
73
- @alternate.setter
74
- def alternate(self, enable: bool) -> None:
75
- """Switch to the alternate screen buffer.
76
- :param enable: alternate enable on/off.
77
- """
78
- if enable != self._alternate:
79
- self._alternate = enable
80
- sysout(f"%SC{'A' if enable else 'M'}%", end="")
81
- self.cursor.track()
82
-
83
- def clear(self) -> None:
84
- """Clear terminal and move the cursor to HOME position (0, 0)."""
85
- self.cursor.home()
86
- self.cursor.erase(Portion.SCREEN)
87
-
88
- def add_watcher(self, watcher: Resize_Cb) -> None:
89
- """Add a resize watcher."""
90
- self._cb_watchers.append(watcher)
91
- if not self._resize_timer:
92
- self._resize_watcher()
93
-
94
- def _resize_watcher(self) -> None:
95
- """Add a watcher for screen resizes. If a resize is detected, the callback is called with the
96
- new dimension."""
97
- if self._cb_watchers and threading.main_thread().is_alive():
98
- dimension: Dimension = get_dimensions()
99
- self._resize_timer = Timer(self.RESIZE_WATCH_INTERVAL, self._resize_watcher)
100
- if dimension != self._dimension:
101
- list(map(lambda cb_w: cb_w(), self._cb_watchers))
102
- self._dimension = dimension
103
- self._resize_timer.start()
104
-
105
-
106
- assert (screen := Screen().INSTANCE) is not None, "Failed to create Screen instance"
@@ -1,202 +0,0 @@
1
- #!/usr/bin/env python3
2
- # -*- coding: utf-8 -*-
3
-
4
- """
5
- @project: HsPyLib
6
- @package: hspylib.modules.cli.vt100
7
- @file: terminal.py
8
- @created: Tue, 11 May 2021
9
- @author: <B>H</B>ugo <B>S</B>aporetti <B>J</B>unior"
10
- @site: https://github.com/yorevs/hspylib
11
- @license: MIT - Please refer to <https://opensource.org/licenses/MIT>
12
-
13
- Copyright·(c)·2024,·HSPyLib
14
- """
15
- from clitt.core.exception.exceptions import NotATerminalError
16
- from clitt.core.term.commons import is_a_tty
17
- from clitt.core.term.cursor import Cursor
18
- from clitt.core.term.screen import Screen
19
- from hspylib.core.enums.charset import Charset
20
- from hspylib.core.metaclass.singleton import Singleton
21
- from hspylib.core.tools.commons import sysout
22
- from hspylib.modules.application.exit_status import ExitStatus
23
- from hspylib.modules.cli.keyboard import Keyboard
24
- from hspylib.modules.cli.vt100.vt_100 import Vt100
25
- from subprocess import CalledProcessError, PIPE, Popen
26
- from typing import Any, Iterable, List, Optional, Tuple
27
-
28
- import atexit
29
- import logging as log
30
- import os
31
- import platform
32
- import select
33
- import shlex
34
- import signal
35
-
36
-
37
- class Terminal(metaclass=Singleton):
38
- """Utility class to provide terminal features."""
39
-
40
- INSTANCE = None
41
-
42
- @staticmethod
43
- def is_a_tty() -> bool:
44
- return is_a_tty()
45
-
46
- @staticmethod
47
- def _chain_pipes(cmd_list: Iterable, **kwargs) -> Popen:
48
- """Run commands in PIPE, return the last process in chain.
49
- :param cmd_list: the command list to be executed.
50
- """
51
- if "stdout" in kwargs:
52
- del kwargs["stdout"]
53
- if "stderr" in kwargs:
54
- del kwargs["stderr"]
55
- if "stdin" in kwargs:
56
- del kwargs["stdin"]
57
- commands = map(shlex.split, cmd_list) if "shell" not in kwargs else cmd_list
58
- first_cmd, *rest_cmds = commands
59
- if len(rest_cmds) > 0:
60
- procs: List[Popen] = [Popen(first_cmd, stdout=PIPE, stderr=PIPE, **kwargs)]
61
- for cmd in rest_cmds:
62
- last_stdout = procs[-1].stdout
63
- procs.append(Popen(cmd, stdin=last_stdout, stdout=PIPE, stderr=PIPE, **kwargs))
64
- return procs[-1]
65
- return Popen(first_cmd, stdout=PIPE, stderr=PIPE, **kwargs)
66
-
67
- @staticmethod
68
- def shell_exec(cmd_line: str, **kwargs) -> Tuple[Optional[str], ExitStatus]:
69
- """Execute command with arguments and return it's run status.
70
- :param cmd_line: the command line to be executed.
71
- """
72
- proc = Terminal._chain_pipes(cmd_line.split("|"), **kwargs)
73
- log.info("Executing shell command: %s", cmd_line)
74
- output, err_out = proc.communicate()
75
- ret_code = ExitStatus.FAILED if err_out else ExitStatus.SUCCESS
76
- log.info("Execution result: %s", ret_code)
77
- return output.decode(Charset.UTF_8.val) if output else err_out.decode(Charset.UTF_8.val), ret_code
78
-
79
- @staticmethod
80
- def shell_poll(cmd_line: str, **kwargs) -> None:
81
- """Execute command with arguments and continuously poll it's output.
82
- :param cmd_line: the command line to be executed.
83
- """
84
- if "stdout" in kwargs:
85
- del kwargs["stdout"] # Deleted because it's forbidden
86
- if "stderr" in kwargs:
87
- del kwargs["stderr"] # Deleted because it's forbidden
88
- if "shell" in kwargs:
89
- del kwargs["shell"] # Deleted because we don't want to use it
90
- try:
91
- log.info("Polling shell command: %s", cmd_line)
92
- cmd_args = list(filter(None, shlex.split(cmd_line)))
93
- with Popen(cmd_args, stdout=PIPE, stderr=PIPE, **kwargs) as proc:
94
- process = select.poll()
95
- process.register(proc.stdout)
96
- process.register(proc.stderr)
97
- while not Keyboard.kbhit():
98
- if poll_obj := process.poll(0.5):
99
- line = proc.stdout.readline()
100
- sysout(line.decode(Charset.UTF_8.val) if isinstance(line, bytes) else line.strip(), end="")
101
- log.debug("Polling returned: %s", str(poll_obj))
102
- os.killpg(os.getpgid(proc.pid), signal.SIGTERM)
103
- except (InterruptedError, KeyboardInterrupt):
104
- log.warning("Polling process has been interrupted command='%s'", cmd_line)
105
- except CalledProcessError as err:
106
- log.error("Command failed: %s => %s", cmd_line, err)
107
-
108
- @staticmethod
109
- def open(filename: str) -> None:
110
- """Open the specified file using the default editor."""
111
- my_os = os.environ.get("HHS_MY_OS", platform.system())
112
- if "Darwin" == my_os:
113
- Terminal.shell_exec(f"open {filename}")
114
- elif "Linux" == my_os:
115
- Terminal.shell_exec(f"xdg-open {filename}")
116
- else:
117
- raise NotImplementedError(f"OS '{my_os}' is not supported")
118
-
119
- @classmethod
120
- def restore(cls) -> None:
121
- """Clear the terminal and restore default attributes [wrap,cursor,echo]."""
122
- cls.set_attributes(show_cursor=True, auto_wrap=True, enable_echo=True)
123
- cls.alternate_screen(False)
124
- sysout("%MOD(0)%", end="")
125
-
126
- @classmethod
127
- def set_enable_echo(cls, enabled: bool = True) -> None:
128
- """Enable echo in the terminal.
129
- :param enabled: whether is enabled or not.
130
- """
131
- if not cls.is_a_tty():
132
- log.warning(NotATerminalError("set_enable_echo:: Requires a terminal (TTY)"))
133
- return
134
-
135
- os.popen(f"stty {'echo -raw' if enabled else 'raw -echo min 0'}").read()
136
-
137
- @classmethod
138
- def set_auto_wrap(cls, auto_wrap: bool = True) -> None:
139
- """Set auto-wrap mode in the terminal.
140
- :param auto_wrap: whether auto_wrap is set or not.
141
- """
142
- if not cls.is_a_tty():
143
- log.warning(NotATerminalError("set_auto_wrap:: Requires a terminal (TTY)"))
144
- return
145
-
146
- sysout(Vt100.set_auto_wrap(auto_wrap), end="")
147
-
148
- @classmethod
149
- def set_show_cursor(cls, show_cursor: bool = True) -> None:
150
- """Show or hide cursor in the terminal.
151
- :param show_cursor: whether to show or hide he cursor.
152
- """
153
- if not cls.is_a_tty():
154
- log.warning(NotATerminalError("set_show_cursor:: Requires a terminal (TTY)"))
155
- return
156
-
157
- sysout(Vt100.set_show_cursor(show_cursor), end="")
158
-
159
- @classmethod
160
- def set_attributes(cls, **attrs) -> None:
161
- """Wrapper to set all terminal attributes at once."""
162
- # fmt: off
163
- enable_echo = attrs['enable_echo']
164
- auto_wrap = attrs['auto_wrap']
165
- show_cursor = attrs['show_cursor']
166
- # fmt: on
167
- if enable_echo is not None:
168
- cls.set_enable_echo(enable_echo)
169
- if auto_wrap is not None:
170
- cls.set_auto_wrap(auto_wrap)
171
- if show_cursor is not None:
172
- cls.set_show_cursor(show_cursor)
173
-
174
- @classmethod
175
- def clear(cls) -> None:
176
- """Clear terminal and move the cursor to HOME position (0, 0)."""
177
- cls.INSTANCE.screen.clear()
178
-
179
- @classmethod
180
- def echo(cls, obj: Any, end: str = os.linesep) -> None:
181
- """Write the string representation of the object to the screen."""
182
- cls.INSTANCE.screen.cursor.write(obj, end=end)
183
-
184
- @classmethod
185
- def alternate_screen(cls, enable: bool) -> None:
186
- """Switch to the alternate screen buffer on/off."""
187
- cls.INSTANCE.screen.alternate = enable
188
-
189
- def __init__(self):
190
- self._screen = Screen.INSTANCE or Screen()
191
- atexit.register(self.restore)
192
-
193
- @property
194
- def screen(self) -> Screen:
195
- return self._screen
196
-
197
- @property
198
- def cursor(self) -> Cursor:
199
- return self.screen.cursor
200
-
201
-
202
- assert (terminal := Terminal().INSTANCE) is not None, "Failed to create Terminal instance"
@@ -1,20 +0,0 @@
1
- # _*_ coding: utf-8 _*_
2
- #
3
- # hspylib-clitt v0.9.120
4
- #
5
- # Package: main.build.lib.build.lib.clitt.core.tui
6
- """Package initialization."""
7
-
8
- __all__ = [
9
- 'line_input',
10
- 'mchoose',
11
- 'mdashboard',
12
- 'menu',
13
- 'minput',
14
- 'mselect',
15
- 'table',
16
- 'tui_application',
17
- 'tui_component',
18
- 'tui_preferences'
19
- ]
20
- __version__ = '0.9.120'
@@ -1,12 +0,0 @@
1
- # _*_ coding: utf-8 _*_
2
- #
3
- # hspylib-clitt v0.9.120
4
- #
5
- # Package: main.build.lib.build.lib.clitt.core.tui.line_input
6
- """Package initialization."""
7
-
8
- __all__ = [
9
- 'keyboard_input',
10
- 'line_input'
11
- ]
12
- __version__ = '0.9.120'