__terminal__ output reappears after clearing the element
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, python
Direzione di ricerca
Inizia in transcrypt/modules/org/transcrypt/runtime.py, nell’implementazione di Terminal e nei binding print/input a livello di modulo collegati nell’issue. Controlla come init imposta l’elemento e come output lo riscrive da self.buffer. Il lavoro è completato quando un metodo clear() reimposta sia buffer sia il contenuto visualizzato, in modo che l’output successivo non ripristini testo obsoleto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- Python
- Stelle
- 2.9k
- Fork
- 218
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di TranscryptOrg/Transcrypt
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
TranscryptOrg/Transcrypt#911 · 2 commenti ·
-
IS: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 62/100
TranscryptOrg/Transcrypt#656 · 7 commenti ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 76/100
TranscryptOrg/Transcrypt#914 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
TranscryptOrg/Transcrypt#910 ·
Tutte le issue di TranscryptOrg/Transcrypt
Issue simili
-
link-check link-check:sphinx-theme
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
qgis/QGIS-Documentation#11275 ·
-
bug priority:normal ready-for-dev
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
OpenHands/extensions#626 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
CSCfi/sd-search-api#39 ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100