Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ANSI.erase erases the wrong side #4021

Closed
csos95 opened this issue Feb 16, 2022 · 1 comment · Fixed by #4022
Closed

ANSI.erase erases the wrong side #4021

csos95 opened this issue Feb 16, 2022 · 1 comment · Fixed by #4022
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@csos95
Copy link
Contributor

csos95 commented Feb 16, 2022

The erase function states that it erases to the left of the cursor, but the escape code it returns uses the value for erasing to the right of the cursor.

fun erase(): String =>
    """
    Erases everything to the left of the cursor on the line the cursor is on.
    """
    "\x1B[0K"

Here's the definition of the erase in line escape code.

Code Abbr Name Effect
CSI n K EL Erase in Line Erases part of the line. If n is 0 (or missing), clear from cursor to the end of the line. If n is 1, clear from cursor to beginning of the line. If n is 2, clear entire line. Cursor position does not change.

Here's an example showing that it erases to the right of the cursor.

use "term"

actor Main
  new create(env: Env) =>
    env.out.print(ANSI.clear() + "12345678901234567890" + ANSI.cursor(10, 1) + ANSI.erase())
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 16, 2022
@SeanTAllen SeanTAllen added bug good first issue Good for newcomers help wanted Extra attention is needed labels Feb 16, 2022
@SeanTAllen
Copy link
Member

This seems like a fairly straightforward bug. Anyone who wants to can open a PR to correct the incorrect code. I don't think this requires additional discussion.

SeanTAllen pushed a commit that referenced this issue Feb 16, 2022
The `erase` function states that it erases to the left of the cursor, but the escape code it returns uses the value for erasing to the right of the cursor.

```pony
fun erase(): String =>
  """
  Erases everything to the left of the cursor on the line the cursor is on.
  """
  "\x1B[0K"
```

Fixes #4021
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 16, 2022
@SeanTAllen SeanTAllen removed the bug label Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants