[PR #2829] [MERGED] Render the cursor state to VT #25100

Open
opened 2026-01-31 09:07:16 +00:00 by claunia · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/microsoft/terminal/pull/2829
Author: @zadjii-msft
Created: 9/20/2019
Status: Merged
Merged: 10/3/2019
Merged by: @carlos-zamora

Base: masterHead: dev/migrie/b/1127-render-cursor-state


📝 Commits (7)

📊 Changes

4 files changed (+192 additions, -70 deletions)

View changed files

📝 src/host/ut_host/VtRendererTests.cpp (+132 -51)
📝 src/renderer/vt/XtermEngine.cpp (+55 -18)
📝 src/renderer/vt/XtermEngine.hpp (+4 -0)
📝 src/renderer/vt/vtrenderer.hpp (+1 -1)

📄 Description

Summary of the Pull Request

Render the visibility state of the cursor to the attached terminal, via the VT renderer.

PR Checklist

Detailed Description of the Pull Request / Additional comments

The trick here is that PaintCursor is only ever called when the cursor is visible, and in PaintCursor, isOn will be on if the cursor is blinked on, and false if the cursor is blinked off. So we need to assume each frame that the cursor is not visible, and update our frame-by-frame tracker only when PaintCursor is called.

Validation Steps Performed

Used the following python script (on windows):

import os
import sys
import time # time.sleep is in seconds

# Turns VT output support on
def enable_vt_support():
    if os.name == 'nt':
        import ctypes
        hOut = ctypes.windll.kernel32.GetStdHandle(-11)
        out_modes = ctypes.c_uint32()
        ENABLE_VT_PROCESSING = ctypes.c_uint32(0x0004)
        # ctypes.addressof()
        ctypes.windll.kernel32.GetConsoleMode(hOut, ctypes.byref(out_modes))
        out_modes = ctypes.c_uint32(out_modes.value | 0x0004)
        ctypes.windll.kernel32.SetConsoleMode(hOut, out_modes)


enable_vt_support()

sys.stdout.write('\x1b[?25h[ Yo ]')
sys.stdout.flush()
time.sleep(1)

sys.stdout.write('\x1b[?25l[Peace out]')

sys.stdout.flush()
time.sleep(1)

I probably should add tests, I'm just putting this out there before I head out for the weekend.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/microsoft/terminal/pull/2829 **Author:** [@zadjii-msft](https://github.com/zadjii-msft) **Created:** 9/20/2019 **Status:** ✅ Merged **Merged:** 10/3/2019 **Merged by:** [@carlos-zamora](https://github.com/carlos-zamora) **Base:** `master` ← **Head:** `dev/migrie/b/1127-render-cursor-state` --- ### 📝 Commits (7) - [`5461faf`](https://github.com/microsoft/terminal/commit/5461faf7656e263c766c658a57ea73ec8fdb68a4) fixes #1127 - [`9096d23`](https://github.com/microsoft/terminal/commit/9096d233e08a84a97710f5577c0fb3ecbd4074ae) This fixes the tests - [`cbe2b6d`](https://github.com/microsoft/terminal/commit/cbe2b6da0d67fb2b5ac8bc9cae4433a13e0ca55c) Remove TestPaintXterm entirely, as it's unused now - [`2e665c0`](https://github.com/microsoft/terminal/commit/2e665c026ded770982c1188beaa6403bdccd6a15) Merge branch 'master' into dev/migrie/b/1127-render-cursor-state - [`26c7bd2`](https://github.com/microsoft/terminal/commit/26c7bd215225088cdf731f09ac840bceafbbe181) Add a test - [`8bdb30f`](https://github.com/microsoft/terminal/commit/8bdb30f9960673821dd1c2f7dd1803059d76d86b) Merge remote-tracking branch 'origin/master' into dev/migrie/b/1127-render-cursor-state - [`7a97d75`](https://github.com/microsoft/terminal/commit/7a97d753bb9df9aeef58c09f8ebeadaf1767360f) nit ### 📊 Changes **4 files changed** (+192 additions, -70 deletions) <details> <summary>View changed files</summary> 📝 `src/host/ut_host/VtRendererTests.cpp` (+132 -51) 📝 `src/renderer/vt/XtermEngine.cpp` (+55 -18) 📝 `src/renderer/vt/XtermEngine.hpp` (+4 -0) 📝 `src/renderer/vt/vtrenderer.hpp` (+1 -1) </details> ### 📄 Description <!-- Enter a brief description/summary of your PR here. What does it fix/what does it change/how was it tested (even manually, if necessary)? --> ## Summary of the Pull Request Render the visibility state of the cursor to the attached terminal, via the VT renderer. <!-- Please review the items on the PR checklist before submitting--> ## PR Checklist * [x] Closes #1127 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments The trick here is that `PaintCursor` is only ever called when the cursor is visible, and in `PaintCursor`, `isOn` will be on if the cursor is blinked on, and false if the cursor is blinked off. So we need to assume each frame that the cursor is not visible, and update our frame-by-frame tracker only when `PaintCursor` is called. ## Validation Steps Performed Used the following python script (on windows): <details> ```python import os import sys import time # time.sleep is in seconds # Turns VT output support on def enable_vt_support(): if os.name == 'nt': import ctypes hOut = ctypes.windll.kernel32.GetStdHandle(-11) out_modes = ctypes.c_uint32() ENABLE_VT_PROCESSING = ctypes.c_uint32(0x0004) # ctypes.addressof() ctypes.windll.kernel32.GetConsoleMode(hOut, ctypes.byref(out_modes)) out_modes = ctypes.c_uint32(out_modes.value | 0x0004) ctypes.windll.kernel32.SetConsoleMode(hOut, out_modes) enable_vt_support() sys.stdout.write('\x1b[?25h[ Yo ]') sys.stdout.flush() time.sleep(1) sys.stdout.write('\x1b[?25l[Peace out]') sys.stdout.flush() time.sleep(1) ``` </details> I probably should add tests, I'm just putting this out there before I head out for the weekend. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
claunia added the pull-request label 2026-01-31 09:07:16 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#25100