Expand description
Cursor save/restore strategy for inline mode robustness.
This module implements a layered cursor save/restore strategy to handle the variety of terminal behaviors. Inline mode requires saving cursor position before drawing UI and restoring after.
§Strategy Layers
-
DEC (preferred):
ESC 7/ESC 8(DECSC/DECRC)- Most widely supported on modern terminals
- Saves cursor position, attributes, and charset
- Works in tmux/screen with passthrough
-
ANSI (fallback):
CSI s/CSI u- Alternative when DEC has issues
- Only saves cursor position (not attributes)
- May conflict with some terminal modes
-
Emulated (last resort): Track position and use
CSI row;col H- Works everywhere that supports CUP
- Requires tracking cursor position throughout
- More overhead but guaranteed to work
§Example
use ftui_core::cursor::{CursorManager, CursorSaveStrategy};
use ftui_core::terminal_capabilities::TerminalCapabilities;
let caps = TerminalCapabilities::detect();
let mut cursor = CursorManager::new(CursorSaveStrategy::detect(&caps));
// In your render loop:
let mut output = Vec::new();
cursor.save(&mut output, (10, 5))?; // Save at column 10, row 5
// ... draw UI ...
cursor.restore(&mut output)?;Structs§
- Cursor
Manager - Manages cursor save/restore operations.
Enums§
- Cursor
Save Strategy - Strategy for cursor save/restore operations.