MCPcopy Create free account
hub / github.com/0xKarl-dev/claw-codes / cursor_layout

Method cursor_layout

rust/crates/claw-cli/src/input.rs:214–230  ·  view source on GitHub ↗
(&self, prompt: &str)

Source from the content-addressed store, hash-verified

212 }
213
214 fn cursor_layout(&self, prompt: &str) -> (usize, usize, usize) {
215 let active_text = self.active_text();
216 let cursor = if self.mode == EditorMode::Command {
217 self.command_cursor
218 } else {
219 self.cursor
220 };
221
222 let cursor_prefix = &active_text[..cursor];
223 let cursor_row = cursor_prefix.bytes().filter(|byte| *byte == b'\n').count();
224 let cursor_col = match cursor_prefix.rsplit_once('\n') {
225 Some((_, suffix)) => suffix.chars().count(),
226 None => prompt.chars().count() + cursor_prefix.chars().count(),
227 };
228 let total_lines = active_text.bytes().filter(|byte| *byte == b'\n').count() + 1;
229 (cursor_row, cursor_col, total_lines)
230 }
231}
232
233enum KeyAction {

Callers 1

renderMethod · 0.80

Calls 1

active_textMethod · 0.80

Tested by

no test coverage detected