__terminal__ output reappears after clearing the element
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, python
Research direction
Start in transcrypt/modules/org/transcrypt/runtime.py at the Terminal implementation and the module-level print/input bindings linked in the issue. Check how init sets the element and how output rewrites it from self.buffer. Done means a clear() method resets both buffer and displayed content so later output does not restore stale text.
Written by the indexing model from the issue text.
Description
Problem
Output written to __terminal__ cannot be cleared. Clearing the target element from application code removes the rendered text only. The next print puts everything back.
Cause
__Terminal__ keeps the output history in self.buffer and rewrites the whole element from that buffer on every call:
The class offers no method to reset self.buffer. Replacing the module-level instance does not help either, because print and input are bound to the original instance when the runtime module is loaded:
Proposed fix
Add a clear() method that resets buffer and element together, so the buffer cannot restore stale output:
def clear (self):
self.buffer = ''
if self.element:
self.element.innerHTML = '_'
'_' is the initial content written by __init__, so clear() returns the terminal to its start state.
Workaround
Reset both parts by hand:
__terminal__.buffer = ''
__terminal__.element.innerHTML = ''
Version
Transcrypt 3.9.5
Contribution
I am happy to write the pull request for this change if the proposed approach is acceptable.
- Dominant language
- Python
- Stars
- 2.9k
- Forks
- 218
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TranscryptOrg/Transcrypt
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
TranscryptOrg/Transcrypt#911 · 2 comments ·
-
IS: bug
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficulty 1/5 Under an hour Newbie friendliness 62/100
TranscryptOrg/Transcrypt#656 · 7 comments ·
-
Difficulty 3/5 1-2 days Newbie friendliness 76/100
TranscryptOrg/Transcrypt#914 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 45/100
TranscryptOrg/Transcrypt#910 ·
All issues in TranscryptOrg/Transcrypt
Similar issues
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
canonical/paas-charm#368 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
tech debt
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
StevenBlack/hosts#3256 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
qualcomm/qai-appbuilder#275 ·