mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-22 12:54:59 +00:00
Fix offsets with long utf sequences
This commit is contained in:
parent
12759fa098
commit
6924612e24
15
src/main.rs
15
src/main.rs
@ -84,7 +84,7 @@ fn main() {
|
|||||||
let output = String::from_utf8_lossy(&execution.stdout);
|
let output = String::from_utf8_lossy(&execution.stdout);
|
||||||
let lines = output.split("\n").collect::<Vec<&str>>();
|
let lines = output.split("\n").collect::<Vec<&str>>();
|
||||||
|
|
||||||
let mut state = state::State::new(lines, alphabet);
|
let mut state = state::State::new(&lines, alphabet);
|
||||||
let mut paste = false;
|
let mut paste = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -125,15 +125,10 @@ fn main() {
|
|||||||
foreground_color
|
foreground_color
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Find long utf sequences and extract it from mat.x
|
// Find long utf sequences and extract it from mat.x
|
||||||
// let re = regex::bytes::Regex::new(r"127").unwrap();
|
let line = &lines[mat.y as usize];
|
||||||
// let line = lines[mat.y as usize];
|
let prefix = &line[0..mat.x as usize];
|
||||||
// let extra = re
|
let extra = prefix.len() - prefix.chars().count();
|
||||||
// .find_iter(line.as_bytes())
|
|
||||||
// .fold(0, |sum, item| sum + item.as_bytes().len());
|
|
||||||
|
|
||||||
let extra = 0;
|
|
||||||
|
|
||||||
let offset = (mat.x as usize) - extra;
|
let offset = (mat.x as usize) - extra;
|
||||||
|
|
||||||
rustbox.print(offset, mat.y as usize, rustbox::RB_NORMAL, selected_color, background_color, mat.text);
|
rustbox.print(offset, mat.y as usize, rustbox::RB_NORMAL, selected_color, background_color, mat.text);
|
||||||
|
@ -29,13 +29,13 @@ impl<'a> PartialEq for Match<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct State<'a> {
|
pub struct State<'a> {
|
||||||
pub lines: Vec<&'a str>,
|
pub lines: &'a Vec<&'a str>,
|
||||||
alphabet: &'a str,
|
alphabet: &'a str,
|
||||||
pub skip: usize,
|
pub skip: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> State<'a> {
|
impl<'a> State<'a> {
|
||||||
pub fn new(lines: Vec<&'a str>, alphabet: &'a str) -> State<'a> {
|
pub fn new(lines: &'a Vec<&'a str>, alphabet: &'a str) -> State<'a> {
|
||||||
State{
|
State{
|
||||||
lines: lines,
|
lines: lines,
|
||||||
alphabet: alphabet,
|
alphabet: alphabet,
|
||||||
|
Loading…
Reference in New Issue
Block a user