mirror of
https://github.com/FliegendeWurst/tmux-thumbs.git
synced 2024-11-09 16:00:35 +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 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;
|
||||
|
||||
{
|
||||
@ -125,15 +125,10 @@ fn main() {
|
||||
foreground_color
|
||||
};
|
||||
|
||||
// TODO: 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 extra = re
|
||||
// .find_iter(line.as_bytes())
|
||||
// .fold(0, |sum, item| sum + item.as_bytes().len());
|
||||
|
||||
let extra = 0;
|
||||
|
||||
// Find long utf sequences and extract it from mat.x
|
||||
let line = &lines[mat.y as usize];
|
||||
let prefix = &line[0..mat.x as usize];
|
||||
let extra = prefix.len() - prefix.chars().count();
|
||||
let offset = (mat.x as usize) - extra;
|
||||
|
||||
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 lines: Vec<&'a str>,
|
||||
pub lines: &'a Vec<&'a str>,
|
||||
alphabet: &'a str,
|
||||
pub skip: usize,
|
||||
}
|
||||
|
||||
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{
|
||||
lines: lines,
|
||||
alphabet: alphabet,
|
||||
|
Loading…
Reference in New Issue
Block a user