PyPlumIO 0.7.7__tar.gz → 0.7.8__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.
Files changed (154) hide show
  1. {pyplumio-0.7.7 → pyplumio-0.7.8}/PKG-INFO +1 -1
  2. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/cli.rst +3 -2
  3. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/ui.py +68 -18
  4. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyproject.toml +1 -1
  5. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_ui.py +95 -5
  6. {pyplumio-0.7.7 → pyplumio-0.7.8}/.gitignore +0 -0
  7. {pyplumio-0.7.7 → pyplumio-0.7.8}/LICENSE +0 -0
  8. {pyplumio-0.7.7 → pyplumio-0.7.8}/README.md +0 -0
  9. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/Makefile +0 -0
  10. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/make.bat +0 -0
  11. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/callbacks.rst +0 -0
  12. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/conf.py +0 -0
  13. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/connecting.rst +0 -0
  14. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/frames.rst +0 -0
  15. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/index.rst +0 -0
  16. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/mixers_thermostats.rst +0 -0
  17. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/protocol.rst +0 -0
  18. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/reading.rst +0 -0
  19. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/schedules.rst +0 -0
  20. {pyplumio-0.7.7 → pyplumio-0.7.8}/docs/source/writing.rst +0 -0
  21. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/__init__.py +0 -0
  22. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/__main__.py +0 -0
  23. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/__init__.py +0 -0
  24. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/app.py +0 -0
  25. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/codegen.py +0 -0
  26. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/model.py +0 -0
  27. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/session.py +0 -0
  28. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/cli/state.py +0 -0
  29. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/connection.py +0 -0
  30. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/const.py +0 -0
  31. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/data_types.py +0 -0
  32. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/devices/__init__.py +0 -0
  33. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/devices/ecomax.py +0 -0
  34. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/devices/ecoster.py +0 -0
  35. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/devices/mixer.py +0 -0
  36. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/devices/thermostat.py +0 -0
  37. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/exceptions.py +0 -0
  38. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/filters.py +0 -0
  39. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/frames/__init__.py +0 -0
  40. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/frames/messages.py +0 -0
  41. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/frames/requests.py +0 -0
  42. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/frames/responses.py +0 -0
  43. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/helpers/__init__.py +0 -0
  44. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/helpers/async_cache.py +0 -0
  45. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/helpers/event_manager.py +0 -0
  46. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/helpers/task_manager.py +0 -0
  47. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/__init__.py +0 -0
  48. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/custom/__init__.py +0 -0
  49. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/custom/ecomax_350p2_zf.py +0 -0
  50. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/custom/ecomax_860d3_hb.py +0 -0
  51. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/custom/ecomax_860p4_nm_touch.py +0 -0
  52. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/ecomax.py +0 -0
  53. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/mixer.py +0 -0
  54. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/parameters/thermostat.py +0 -0
  55. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/protocol.py +0 -0
  56. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/py.typed +0 -0
  57. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/stream.py +0 -0
  58. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/__init__.py +0 -0
  59. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/alerts.py +0 -0
  60. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/ecomax_parameters.py +0 -0
  61. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/ecomax_service_parameters.py +0 -0
  62. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/frame_versions.py +0 -0
  63. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/mixer_parameters.py +0 -0
  64. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/network_info.py +0 -0
  65. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/product_info.py +0 -0
  66. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/program_version.py +0 -0
  67. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/regulator_data.py +0 -0
  68. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/regulator_data_schema.py +0 -0
  69. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/schedules.py +0 -0
  70. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/sensor_data.py +0 -0
  71. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/structures/thermostat_parameters.py +0 -0
  72. {pyplumio-0.7.7 → pyplumio-0.7.8}/pyplumio/utils.py +0 -0
  73. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/__init__.py +0 -0
  74. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/__init__.py +0 -0
  75. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/conftest.py +0 -0
  76. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_app.py +0 -0
  77. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_codegen.py +0 -0
  78. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_init.py +0 -0
  79. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_model.py +0 -0
  80. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_session.py +0 -0
  81. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/cli/test_state.py +0 -0
  82. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/conftest.py +0 -0
  83. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/__init__.py +0 -0
  84. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/test_ecomax.py +0 -0
  85. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/test_ecoster.py +0 -0
  86. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/test_init.py +0 -0
  87. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/test_mixer.py +0 -0
  88. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/devices/test_thermostat.py +0 -0
  89. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/frames/test_init.py +0 -0
  90. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/frames/test_messages.py +0 -0
  91. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/frames/test_requests.py +0 -0
  92. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/frames/test_responses.py +0 -0
  93. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/helpers/__init__.py +0 -0
  94. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/helpers/test_async_cache.py +0 -0
  95. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/helpers/test_event_manager.py +0 -0
  96. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/helpers/test_task_manager.py +0 -0
  97. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/helpers/test_uid.py +0 -0
  98. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/__init__.py +0 -0
  99. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/custom/__init__.py +0 -0
  100. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/custom/test_ecomax_350p2_zf.py +0 -0
  101. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/custom/test_ecomax_860d3_hb.py +0 -0
  102. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/custom/test_ecomax_860p4_nm_touch.py +0 -0
  103. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/custom/test_init.py +0 -0
  104. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/test_ecomax.py +0 -0
  105. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/test_init.py +0 -0
  106. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/test_mixers.py +0 -0
  107. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/parameters/test_thermostats.py +0 -0
  108. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/ruff.toml +0 -0
  109. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/__init__.py +0 -0
  110. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_alerts.py +0 -0
  111. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_ecomax_parameters.py +0 -0
  112. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_ecomax_service_parameters.py +0 -0
  113. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_frame_versions.py +0 -0
  114. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_mixer_parameters.py +0 -0
  115. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_product_info.py +0 -0
  116. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_program_version.py +0 -0
  117. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/structures/test_schedules.py +0 -0
  118. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_connection.py +0 -0
  119. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_data_types.py +0 -0
  120. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_filters.py +0 -0
  121. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_init.py +0 -0
  122. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_main.py +0 -0
  123. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_protocol.py +0 -0
  124. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_stream.py +0 -0
  125. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/test_utils.py +0 -0
  126. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/messages/regulator_data.json +0 -0
  127. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/messages/sensor_data.json +0 -0
  128. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/parameters/ecomax_350p2_zf.json +0 -0
  129. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/parameters/ecomax_860d3_hb.json +0 -0
  130. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/parameters/ecomax_860p4_nm_touch.json +0 -0
  131. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/alerts.json +0 -0
  132. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/ecomax_control.json +0 -0
  133. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/ecomax_parameters.json +0 -0
  134. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/ecomax_service_parameters.json +0 -0
  135. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/mixer_parameters.json +0 -0
  136. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/set_ecomax_parameter.json +0 -0
  137. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/set_ecomax_service_parameter.json +0 -0
  138. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/set_mixer_parameter.json +0 -0
  139. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/set_schedule.json +0 -0
  140. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/set_thermostat_parameter.json +0 -0
  141. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/requests/thermostat_parameters.json +0 -0
  142. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/alerts.json +0 -0
  143. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/device_available.json +0 -0
  144. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/ecomax_parameters.json +0 -0
  145. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/ecomax_service_parameters.json +0 -0
  146. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/mixer_parameters.json +0 -0
  147. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/password.json +0 -0
  148. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/program_version.json +0 -0
  149. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/regulator_data_schema.json +0 -0
  150. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/schedules.json +0 -0
  151. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/thermostat_parameters.json +0 -0
  152. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/responses/uid.json +0 -0
  153. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/unknown/unknown_ecomax_parameter.json +0 -0
  154. {pyplumio-0.7.7 → pyplumio-0.7.8}/tests/testdata/unknown/unknown_mixer_parameter.json +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: PyPlumIO
3
- Version: 0.7.7
3
+ Version: 0.7.8
4
4
  Summary: PyPlumIO is a native ecoNET library for Plum ecoMAX controllers.
5
5
  Project-URL: Documentation, https://pyplumio.denpa.pro
6
6
  Project-URL: Source Code, https://github.com/denpamusic/PyPlumIO
@@ -85,10 +85,11 @@ polling in the background.
85
85
 
86
86
  The interface consists of:
87
87
 
88
- - **Header**: Shows connected controller model, product ID, connection URL, last update timestamp, and keyboard shortcuts.
88
+ - **Header**: Inverted top bar showing connected controller model, product ID, connection URL, and last update timestamp.
89
89
  - **Table**: Monospace scrollable list showing parameter indices, mapped names, current values, minimums, and maximums. Recently changed parameters are highlighted with inverted colors.
90
90
  - **Live Preview**: Real-time 4-line framed box docked above the input bar displaying active parameter fields, raw values, and live calculations.
91
- - **Navigation**: Use Up/Down arrow keys or ``PageUp`` and ``PageDown`` to scroll through the parameters list.
91
+ - **Status Bar**: Inverted bar positioned below the input prompt and directly above the hotkey bar displaying validation messages, available units, and connection status.
92
+ - **Hotkey Bar**: Bottom bar displaying keyboard shortcuts (``^S`` Save, ``^Q`` Quit, ``Esc`` Cancel, ``↑/↓`` Scroll, ``PgUp/PgDn`` Page, ``Tab`` Complete).
92
93
 
93
94
  Interactive Wizard
94
95
  ~~~~~~~~~~~~~~~~~~
@@ -5,6 +5,7 @@ from __future__ import annotations
5
5
  from contextlib import suppress
6
6
  from dataclasses import replace
7
7
  from pathlib import Path
8
+ import textwrap
8
9
  from typing import Any, Final
9
10
 
10
11
  from prompt_toolkit.application import Application
@@ -49,11 +50,26 @@ from pyplumio.parameters.ecomax import (
49
50
  )
50
51
 
51
52
  SCROLL_SIZE: Final = 20
52
- PREVIEW_BOX_WIDTH: Final = 78
53
+ PREVIEW_BOX_WIDTH: Final = 80
54
+ ELLIPSIS: Final = "..."
53
55
  TABLE_HEADER: Final = (
54
56
  "Index Name Value Min Max\n"
55
57
  )
56
58
  TABLE_SEPARATOR: Final = f"{'-' * 5} {'-' * 36} {'-' * 10} {'-' * 10} {'-' * 10}\n"
59
+ HOTKEY_BAR: Final[StyleAndTextTuples] = [
60
+ ("reverse", "^S"),
61
+ ("", " Save "),
62
+ ("reverse", "^Q"),
63
+ ("", " Quit "),
64
+ ("reverse", "Esc"),
65
+ ("", " Cancel "),
66
+ ("reverse", "↑/↓"),
67
+ ("", " Scroll "),
68
+ ("reverse", "PgUp/PgDn"),
69
+ ("", " Page "),
70
+ ("reverse", "Tab"),
71
+ ("", " Complete"),
72
+ ]
57
73
 
58
74
  TYPE_COMPLETER: Final = WordCompleter(list(_ParameterType))
59
75
  UNIT_COMPLETER: Final = WordCompleter(
@@ -70,21 +86,48 @@ UNIT_COMPLETER: Final = WordCompleter(
70
86
  )
71
87
 
72
88
 
89
+ def _truncate_middle(text: str, max_length: int) -> str:
90
+ """Truncate text in the middle with an ellipsis to fit max_length."""
91
+ if len(text) <= max_length:
92
+ return text
93
+
94
+ if max_length <= len(ELLIPSIS):
95
+ return ELLIPSIS[: max(0, max_length)]
96
+
97
+ head = (max_length - len(ELLIPSIS)) // 2
98
+ tail = max_length - len(ELLIPSIS) - head
99
+ return f"{text[:head]}{ELLIPSIS}{text[-tail:]}"
100
+
101
+
73
102
  def _get_header_text(state: AppState) -> StyleAndTextTuples:
74
103
  """Return formatted header text."""
75
104
  product_info = state.session.product_info
76
- last_update = state.session.last_update_time
77
- model, product_id = (
78
- (product_info.model, product_info.id) if product_info else ("Unknown", 0)
105
+ model = product_info.model if product_info else "Unknown"
106
+ product_id = product_info.id if product_info else 0
107
+ updated = (
108
+ state.session.last_update_time.strftime("%H:%M:%S")
109
+ if state.session.last_update_time
110
+ else "Never"
79
111
  )
80
- updated = last_update.strftime("%H:%M:%S") if last_update else "Never"
81
- return [
82
- (
83
- "bold",
84
- f"Model: {model} (ID: {product_id}) | URL: {state.session.url} | "
85
- f"Updated: {updated} | Ctrl+S save · Ctrl+Q quit\n",
86
- )
87
- ]
112
+ left = f" {model} (ID: {product_id})"
113
+ right = f"↻ {updated} "
114
+ middle_width = PREVIEW_BOX_WIDTH - len(left) - len(right)
115
+ url = _truncate_middle(state.session.url, middle_width - 4)
116
+ return [("reverse", f"{left}{url.center(middle_width)}{right}")]
117
+
118
+
119
+ def _get_status_text(state: AppState) -> StyleAndTextTuples:
120
+ """Return formatted status bar text."""
121
+ if not state.status.strip():
122
+ return []
123
+
124
+ lines = textwrap.wrap(
125
+ state.status,
126
+ width=PREVIEW_BOX_WIDTH,
127
+ break_long_words=True,
128
+ break_on_hyphens=False,
129
+ )
130
+ return [("reverse", "\n".join(line.center(PREVIEW_BOX_WIDTH) for line in lines))]
88
131
 
89
132
 
90
133
  def _get_table_text(state: AppState) -> StyleAndTextTuples:
@@ -365,18 +408,17 @@ def create_app(
365
408
  key_bindings = _create_key_bindings(state, buffer)
366
409
  body = HSplit(
367
410
  [
368
- Window(FormattedTextControl(lambda: _get_header_text(state)), height=2),
411
+ Window(
412
+ FormattedTextControl(lambda: _get_header_text(state)),
413
+ height=1,
414
+ ),
415
+ Window(height=1),
369
416
  Window(FormattedTextControl(lambda: _get_table_text(state))),
370
417
  Window(height=1),
371
418
  Window(
372
419
  FormattedTextControl(lambda: _get_preview_text(state, buffer)),
373
420
  height=4,
374
421
  ),
375
- Window(
376
- FormattedTextControl(lambda: f" {state.status}"),
377
- wrap_lines=True,
378
- dont_extend_height=True,
379
- ),
380
422
  VSplit(
381
423
  [
382
424
  Window(
@@ -386,6 +428,14 @@ def create_app(
386
428
  Window(BufferControl(buffer=buffer)),
387
429
  ]
388
430
  ),
431
+ Window(height=1),
432
+ Window(
433
+ FormattedTextControl(lambda: _get_status_text(state)),
434
+ width=PREVIEW_BOX_WIDTH,
435
+ wrap_lines=True,
436
+ dont_extend_height=True,
437
+ ),
438
+ Window(FormattedTextControl(HOTKEY_BAR), height=1),
389
439
  ]
390
440
  )
391
441
  root = FloatContainer(
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "PyPlumIO"
3
- version = "0.7.7"
3
+ version = "0.7.8"
4
4
  authors = [
5
5
  {name = "Denis Paavilainen", email = "denpa@denpa.pro"}
6
6
  ]
@@ -13,19 +13,23 @@ from prompt_toolkit.completion import CompleteEvent
13
13
  from prompt_toolkit.document import Document
14
14
  from prompt_toolkit.formatted_text import OneStyleAndTextTuple
15
15
  from prompt_toolkit.key_binding import KeyPressEvent
16
+ from prompt_toolkit.layout.containers import VSplit
16
17
  from prompt_toolkit.output import DummyOutput
17
18
 
18
19
  from pyplumio.cli.model import ParameterTable
19
20
  from pyplumio.cli.session import Session
20
21
  from pyplumio.cli.state import AppState, AppStep
21
22
  from pyplumio.cli.ui import (
23
+ HOTKEY_BAR,
22
24
  PREVIEW_BOX_WIDTH,
23
25
  TABLE_HEADER,
24
26
  TABLE_SEPARATOR,
25
27
  _get_completer,
26
28
  _get_header_text,
27
29
  _get_preview_text,
30
+ _get_status_text,
28
31
  _get_table_text,
32
+ _truncate_middle,
29
33
  create_app,
30
34
  )
31
35
  from pyplumio.const import PERCENTAGE, UnitOfMeasurement
@@ -71,15 +75,24 @@ def test_ui_header_and_table_text(tmp_path: Path) -> None:
71
75
 
72
76
  # Initial header without product info or update time
73
77
  header = _get_header_text(state)
74
- assert "Model: Unknown (ID: 0)" in header[0][1]
75
- assert "Updated: Never" in header[0][1]
78
+ assert header[0][0] == "reverse"
79
+ assert len(header[0][1]) == PREVIEW_BOX_WIDTH
80
+ assert header[0][1].startswith(" Unknown (ID: 0) ")
81
+ assert "socket://localhost:8899" in header[0][1]
82
+ assert header[0][1].endswith(" ↻ Never ")
83
+ assert "Model:" not in header[0][1]
84
+ assert "URL:" not in header[0][1]
85
+ assert "Updated:" not in header[0][1]
76
86
 
77
87
  # Header with product info and update time
78
88
  session.product_info = dummy_product_info()
79
89
  session.last_update_time = datetime(2025, 1, 1, 12, 0, 0, tzinfo=UTC)
80
90
  header = _get_header_text(state)
81
- assert f"Model: {DUMMY_MODEL} (ID: {DUMMY_ID})" in header[0][1]
82
- assert "Updated: 12:00:00" in header[0][1]
91
+ assert header[0][0] == "reverse"
92
+ assert len(header[0][1]) == PREVIEW_BOX_WIDTH
93
+ assert header[0][1].startswith(f" {DUMMY_MODEL} (ID: {DUMMY_ID}) ")
94
+ assert "socket://localhost:8899" in header[0][1]
95
+ assert header[0][1].endswith(" ↻ 12:00:00 ")
83
96
 
84
97
  # Table text without description
85
98
  table.update([(0, ParameterValues(value=10, min_value=0, max_value=20))])
@@ -472,7 +485,7 @@ def test_app_keybindings_and_layout(tmp_path: Path) -> None:
472
485
  assert state.status == "Cancelled."
473
486
 
474
487
  # 4. live preview container check
475
- preview_win = app.layout.container.content.children[3] # type: ignore[attr-defined]
488
+ preview_win = app.layout.container.content.children[4] # type: ignore[attr-defined]
476
489
  assert preview_win.height == 4
477
490
  preview_output = preview_win.content.text()
478
491
  assert "Live Preview" in preview_output[0][1]
@@ -845,3 +858,80 @@ async def test_zip_save_flag(tmp_path: Path) -> None:
845
858
  assert _step(state) == AppStep.INDEX
846
859
  assert state.status == f"Files saved to {zip_path}."
847
860
  assert state.data.save_as_zip is False
861
+
862
+
863
+ def test_ui_header_url_truncation(tmp_path: Path) -> None:
864
+ """Test middle truncation of long URLs in the single-line header."""
865
+ session = Session(
866
+ url="/dev/serial/by-id/usb-FTDI_FT232R_USB_UART_A50285BI-if00-port0"
867
+ )
868
+ session.product_info = dummy_product_info()
869
+ session.last_update_time = datetime(2025, 1, 1, 12, 0, 0, tzinfo=UTC)
870
+ table = ParameterTable()
871
+ state = AppState(session, table, tmp_path)
872
+
873
+ header = _get_header_text(state)
874
+ assert header[0][0] == "reverse"
875
+ assert "\n" not in header[0][1]
876
+ assert len(header[0][1]) == PREVIEW_BOX_WIDTH
877
+ assert header[0][1].startswith(f" {DUMMY_MODEL} (ID: {DUMMY_ID}) ")
878
+ assert header[0][1].endswith(" ↻ 12:00:00 ")
879
+ assert "/dev/serial/" in header[0][1]
880
+ assert "..." in header[0][1]
881
+ assert "-port0" in header[0][1]
882
+
883
+ # Edge cases for _truncate_middle
884
+ assert _truncate_middle("abcdef", 6) == "abcdef"
885
+ assert _truncate_middle("abcdef", 5) == "a...f"
886
+ assert _truncate_middle("abcdef", 4) == "...f"
887
+ assert _truncate_middle("abcdef", 3) == "..."
888
+ assert _truncate_middle("abcdef", 2) == ".."
889
+ assert _truncate_middle("abcdef", 0) == ""
890
+ assert _truncate_middle("abcdef", -3) == ""
891
+
892
+
893
+ def test_app_layout_header_and_hotkey_bar(tmp_path: Path) -> None:
894
+ """Test header, preview, prompt, status, spacer, and hotkey bar layout."""
895
+ session = Session(url="socket://localhost:8899")
896
+ table = ParameterTable()
897
+ app, state = create_app(session, table, tmp_path, output=DummyOutput())
898
+ children = app.layout.container.content.children # type: ignore[attr-defined]
899
+
900
+ header_win = children[0]
901
+ assert header_win.height == 1
902
+ assert children[1].height == 1
903
+ assert children[3].height == 1
904
+ assert children[4].height == 4
905
+ assert isinstance(children[5], VSplit)
906
+ assert children[6].height == 1
907
+
908
+ status_win = children[7]
909
+ assert status_win.width == PREVIEW_BOX_WIDTH
910
+ assert status_win.dont_extend_height() is True
911
+ assert status_win.wrap_lines() is True
912
+ assert state.status == ""
913
+ assert _get_status_text(state) == []
914
+ assert status_win.content.text() == []
915
+ assert status_win.preferred_height(PREVIEW_BOX_WIDTH, 24).preferred == 1
916
+
917
+ state.status = " "
918
+ assert _get_status_text(state) == []
919
+ assert status_win.content.text() == []
920
+
921
+ state.status = "Cancelled."
922
+ assert status_win.content.text() == [
923
+ ("reverse", "Cancelled.".center(PREVIEW_BOX_WIDTH))
924
+ ]
925
+
926
+ state.status = "a " * 50
927
+ wrapped_status = _get_status_text(state)
928
+ assert wrapped_status[0][0] == "reverse"
929
+ assert "\n" in wrapped_status[0][1]
930
+ wrapped_lines = wrapped_status[0][1].splitlines()
931
+ assert all(len(line) == PREVIEW_BOX_WIDTH for line in wrapped_lines)
932
+ assert wrapped_lines[1].startswith(" ") and wrapped_lines[1].endswith(" ")
933
+
934
+ hotkey_win = children[8]
935
+ assert hotkey_win.height == 1
936
+ assert hotkey_win.content.text == HOTKEY_BAR
937
+ assert len("".join(item[1] for item in HOTKEY_BAR)) == PREVIEW_BOX_WIDTH
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes