__terminal__ output reappears after clearing the element
还没有人认领这个 Issue。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 84/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, python
调研方向
从 transcrypt/modules/org/transcrypt/runtime.py 中的 Terminal 实现以及 issue 中链接的模块级 print/input 绑定开始。检查 init 如何设置元素,以及 output 如何从 self.buffer 重新写入该元素。完成的标准是:clear() 方法会同时重置 buffer 和显示内容,使后续输出不会恢复过时的文本。
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- Python
- 星标
- 2.9k
- 派生
- 218
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
TranscryptOrg/Transcrypt 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 88/100
TranscryptOrg/Transcrypt#911 · 2 条评论 ·
-
IS: bug
难度 2/5 1-3 小时 新手友好度 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
难度 1/5 1 小时以内 新手友好度 62/100
TranscryptOrg/Transcrypt#656 · 7 条评论 ·
-
难度 3/5 1-2 天 新手友好度 76/100
TranscryptOrg/Transcrypt#914 ·
-
难度 4/5 3-5 天 新手友好度 45/100
TranscryptOrg/Transcrypt#910 ·
查看 TranscryptOrg/Transcrypt 的全部 Issue
相似的 Issue
-
triage/confirmed
难度 2/5 1-3 小时 新手友好度 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
难度 1/5 1 小时以内 新手友好度 92/100
NousResearch/hermes-agent#118866 ·
-
bug
难度 1/5 1 小时以内 新手友好度 90/100
apache/cloudstack#14222 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
-
bug
难度 2/5 1-3 小时 新手友好度 82/100