MCPcopy Create free account
hub / github.com/GCWing/BitFun / cursor_line_col

Method cursor_line_col

src/apps/cli/src/ui/text_input.rs:119–132  ·  view source on GitHub ↗

Returns (logical_line, col_in_line, char_offset_of_line_start)

(&self)

Source from the content-addressed store, hash-verified

117
118 /// Returns (logical_line, col_in_line, char_offset_of_line_start)
119 pub fn cursor_line_col(&self) -> (usize, usize, usize) {
120 let mut line = 0;
121 let mut line_start = 0usize;
122 for (i, ch) in self.input.chars().enumerate() {
123 if i == self.cursor {
124 return (line, self.cursor - line_start, line_start);
125 }
126 if ch == '\n' {
127 line += 1;
128 line_start = i + 1;
129 }
130 }
131 (line, self.cursor - line_start, line_start)
132 }
133
134 fn input_line_char_counts(&self) -> Vec<usize> {
135 self.input.split('\n').map(|l| l.chars().count()).collect()

Callers 5

move_cursor_upMethod · 0.80
move_cursor_downMethod · 0.80
set_cursor_homeMethod · 0.80
set_cursor_endMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected