Fix editor cursor positioning
This commit is contained in:
parent
1e4bbc6eab
commit
a5757d4660
3 changed files with 6 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -1241,7 +1241,7 @@ dependencies = [
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "toss"
|
name = "toss"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
source = "git+https://github.com/Garmelon/toss.git?rev=53b2728c827c9f93a743d5860c1b31cb1399875b#53b2728c827c9f93a743d5860c1b31cb1399875b"
|
source = "git+https://github.com/Garmelon/toss.git?rev=c1907bb8ee215d534daf4188824293203b60dd9c#c1907bb8ee215d534daf4188824293203b60dd9c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"crossterm",
|
"crossterm",
|
||||||
"unicode-linebreak",
|
"unicode-linebreak",
|
||||||
|
|
|
||||||
|
|
@ -30,4 +30,7 @@ features = ["rustls-tls-native-roots"]
|
||||||
|
|
||||||
[dependencies.toss]
|
[dependencies.toss]
|
||||||
git = "https://github.com/Garmelon/toss.git"
|
git = "https://github.com/Garmelon/toss.git"
|
||||||
rev = "53b2728c827c9f93a743d5860c1b31cb1399875b"
|
rev = "c1907bb8ee215d534daf4188824293203b60dd9c"
|
||||||
|
|
||||||
|
# [patch."https://github.com/Garmelon/toss.git"]
|
||||||
|
# toss = { path = "../toss/" }
|
||||||
|
|
|
||||||
|
|
@ -285,7 +285,7 @@ impl Widget for Editor {
|
||||||
|
|
||||||
let (cursor_row, cursor_line_idx) = Self::wrapped_cursor(self.idx, &indices);
|
let (cursor_row, cursor_line_idx) = Self::wrapped_cursor(self.idx, &indices);
|
||||||
let cursor_col = frame.width(lines[cursor_row].text().split_at(cursor_line_idx).0);
|
let cursor_col = frame.width(lines[cursor_row].text().split_at(cursor_line_idx).0);
|
||||||
frame.set_cursor(Some(Pos::new(cursor_row as i32, cursor_col as i32)));
|
frame.set_cursor(Some(Pos::new(cursor_col as i32, cursor_row as i32)));
|
||||||
|
|
||||||
for (i, line) in lines.into_iter().enumerate() {
|
for (i, line) in lines.into_iter().enumerate() {
|
||||||
frame.write(Pos::new(0, i as i32), line);
|
frame.write(Pos::new(0, i as i32), line);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue