set OSC 6 (current document)
This commit is contained in:
+1
-1
@@ -57,7 +57,7 @@ impl App {
|
|||||||
let mut buffers: Vec<Buffer> = files
|
let mut buffers: Vec<Buffer> = files
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|path| {
|
.filter_map(|path| {
|
||||||
Buffer::from_file_at(path.clone())
|
Buffer::from_file_at(path)
|
||||||
.inspect_err(|error| {
|
.inspect_err(|error| {
|
||||||
error_alert = Some(
|
error_alert = Some(
|
||||||
Span::raw(format!("error reading '{}': {error}", path.display())).red()
|
Span::raw(format!("error reading '{}': {error}", path.display())).red()
|
||||||
|
|||||||
+4
-2
@@ -1,4 +1,4 @@
|
|||||||
use std::{collections::HashSet, fs::File, io::{self, Read}, path::PathBuf};
|
use std::{collections::HashSet, fs::File, io::{self, Read}, path::{Path, PathBuf}};
|
||||||
use crossterm::event::KeyEvent;
|
use crossterm::event::KeyEvent;
|
||||||
use ratatui::{style::Stylize, text::Span};
|
use ratatui::{style::Stylize, text::Span};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
@@ -75,7 +75,9 @@ impl TryFrom<&str> for PartialAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Buffer {
|
impl Buffer {
|
||||||
pub fn from_file_at(file_path: PathBuf) -> io::Result<Self> {
|
pub fn from_file_at(file_path: &Path) -> io::Result<Self> {
|
||||||
|
let file_path = file_path.canonicalize()?;
|
||||||
|
|
||||||
let mut file = File::open(&file_path)?;
|
let mut file = File::open(&file_path)?;
|
||||||
let mut contents = Vec::new();
|
let mut contents = Vec::new();
|
||||||
file.read_to_end(&mut contents)?;
|
file.read_to_end(&mut contents)?;
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ mod extra_statuses;
|
|||||||
|
|
||||||
impl Widget for &Buffer {
|
impl Widget for &Buffer {
|
||||||
fn render(self, area: Rect, buf: &mut ratatui::buffer::Buffer) {
|
fn render(self, area: Rect, buf: &mut ratatui::buffer::Buffer) {
|
||||||
|
// set OSC 6 (current document)
|
||||||
|
print!("\x1B]6;{}\x07", self.file_path.display());
|
||||||
|
|
||||||
let screen_end = self.scroll_position + BYTES_PER_LINE * (area.height as usize - 1);
|
let screen_end = self.scroll_position + BYTES_PER_LINE * (area.height as usize - 1);
|
||||||
let bytes_end = min(screen_end, self.contents.len());
|
let bytes_end = min(screen_end, self.contents.len());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user