Skip to content

Commit 096d8de

Browse files
committed
Renamed functions in cmd2.ansi.Cursor to start with underscore to make it clear they are intended for internal use only
1 parent 9e750bb commit 096d8de

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
- Breaking Change
44
- `cmd2` 2.6 supports Python 3.9+ (removed support for Python 3.8)
5+
- Renamed methods in `cmd2.ansi.Cursor` to make it clear they are intended for internal use only as was documented
56
- Enhancements
67
- Add support for Python 3.14
78

cmd2/ansi.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,27 @@ class Cursor:
213213
"""Create ANSI sequences to alter the cursor position."""
214214

215215
@staticmethod
216-
def up(count: int = 1) -> str:
216+
def _up(count: int = 1) -> str:
217217
"""Move the cursor up a specified amount of lines (Defaults to 1)."""
218218
return f"{CSI}{count}A"
219219

220220
@staticmethod
221-
def down(count: int = 1) -> str:
221+
def _down(count: int = 1) -> str:
222222
"""Move the cursor down a specified amount of lines (Defaults to 1)."""
223223
return f"{CSI}{count}B"
224224

225225
@staticmethod
226-
def forward(count: int = 1) -> str:
226+
def _forward(count: int = 1) -> str:
227227
"""Move the cursor forward a specified amount of lines (Defaults to 1)."""
228228
return f"{CSI}{count}C"
229229

230230
@staticmethod
231-
def back(count: int = 1) -> str:
231+
def _back(count: int = 1) -> str:
232232
"""Move the cursor back a specified amount of lines (Defaults to 1)."""
233233
return f"{CSI}{count}D"
234234

235235
@staticmethod
236-
def set_pos(x: int, y: int) -> str:
236+
def _set_pos(x: int, y: int) -> str:
237237
"""Set the cursor position to coordinates which are 1-based."""
238238
return f"{CSI}{y};{x}H"
239239

@@ -1059,11 +1059,11 @@ def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_off
10591059

10601060
# Move the cursor down to the last input line
10611061
if cursor_input_line != num_input_terminal_lines:
1062-
terminal_str += Cursor.down(num_input_terminal_lines - cursor_input_line)
1062+
terminal_str += Cursor._down(num_input_terminal_lines - cursor_input_line)
10631063

10641064
# Clear each line from the bottom up so that the cursor ends up on the first prompt line
10651065
total_lines = num_prompt_terminal_lines + num_input_terminal_lines
1066-
terminal_str += (clear_line() + Cursor.up(1)) * (total_lines - 1)
1066+
terminal_str += (clear_line() + Cursor._up(1)) * (total_lines - 1)
10671067

10681068
# Clear the first prompt line
10691069
terminal_str += clear_line()

tests/test_ansi.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -202,14 +202,14 @@ def test_clear_line() -> None:
202202

203203
def test_cursor() -> None:
204204
count = 1
205-
assert ansi.Cursor.up(count) == f"{ansi.CSI}{count}A"
206-
assert ansi.Cursor.down(count) == f"{ansi.CSI}{count}B"
207-
assert ansi.Cursor.forward(count) == f"{ansi.CSI}{count}C"
208-
assert ansi.Cursor.back(count) == f"{ansi.CSI}{count}D"
205+
assert ansi.Cursor._up(count) == f"{ansi.CSI}{count}A"
206+
assert ansi.Cursor._down(count) == f"{ansi.CSI}{count}B"
207+
assert ansi.Cursor._forward(count) == f"{ansi.CSI}{count}C"
208+
assert ansi.Cursor._back(count) == f"{ansi.CSI}{count}D"
209209

210210
x = 4
211211
y = 5
212-
assert ansi.Cursor.set_pos(x, y) == f"{ansi.CSI}{y};{x}H"
212+
assert ansi.Cursor._set_pos(x, y) == f"{ansi.CSI}{y};{x}H"
213213

214214

215215
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)