mirror of
https://github.com/rust-kotlin/ashell.git
synced 2026-10-03 16:00:18 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd866d1400 |
@@ -125,8 +125,6 @@ pub struct ConfigFile {
|
||||
pub body_panels: Option<Vec<f32>>,
|
||||
#[serde(default)]
|
||||
pub transfers: Vec<crate::terminal::Transfer>,
|
||||
#[serde(default)]
|
||||
pub show_hidden_files: bool,
|
||||
}
|
||||
|
||||
fn default_locale() -> String {
|
||||
@@ -333,14 +331,6 @@ impl ConfigStore {
|
||||
self.cache.terminal_font_family = family.to_string();
|
||||
}
|
||||
|
||||
pub fn show_hidden_files(&self) -> bool {
|
||||
self.cache.show_hidden_files
|
||||
}
|
||||
|
||||
pub fn set_show_hidden_files(&mut self, val: bool) {
|
||||
self.cache.show_hidden_files = val;
|
||||
}
|
||||
|
||||
pub fn get(&self, id: &str) -> Option<&Session> {
|
||||
self.cache.sessions.iter().find(|s| s.id == id)
|
||||
}
|
||||
|
||||
+19
-33
@@ -338,7 +338,7 @@ impl Ashell {
|
||||
sftp_creating_folder: false,
|
||||
sftp_new_folder_input,
|
||||
sftp_delete_scroll_handle: gpui::ScrollHandle::new(),
|
||||
show_hidden_files: config.show_hidden_files(),
|
||||
show_hidden_files: false,
|
||||
transfers: config.transfers(),
|
||||
show_transfers_dialog: false,
|
||||
system_status: None,
|
||||
@@ -819,21 +819,12 @@ impl Ashell {
|
||||
self.show_ssh_dialog(window, cx);
|
||||
}
|
||||
|
||||
fn terminal_cell_width(&self, window: &Window) -> f32 {
|
||||
let font_id = window.text_system().resolve_font(&gpui::Font {
|
||||
family: self.terminal_font_family.clone(),
|
||||
..gpui::Font::default()
|
||||
});
|
||||
window
|
||||
.text_system()
|
||||
.advance(font_id, px(self.terminal_font_size), 'm')
|
||||
.map(|a| a.width.as_f32())
|
||||
.unwrap_or(self.terminal_font_size * 0.646)
|
||||
.max(6.0)
|
||||
fn terminal_cell_width(&self) -> f32 {
|
||||
(self.terminal_font_size * 0.646).max(6.0)
|
||||
}
|
||||
|
||||
fn terminal_line_height(&self) -> f32 {
|
||||
(self.terminal_font_size * 1.3).max(self.terminal_font_size + 2.0)
|
||||
(self.terminal_font_size * 1.385).max(self.terminal_font_size + 2.0)
|
||||
}
|
||||
|
||||
fn change_terminal_font_size(&mut self, delta: f32, cx: &mut Context<Self>) {
|
||||
@@ -2792,20 +2783,18 @@ impl Ashell {
|
||||
&self,
|
||||
range_utf16: Range<usize>,
|
||||
element_bounds: Bounds<Pixels>,
|
||||
cell_width: f32,
|
||||
line_height: f32,
|
||||
) -> Option<Bounds<Pixels>> {
|
||||
let snapshot = self.active_snapshot()?;
|
||||
let cursor = snapshot.cursor?;
|
||||
let x = element_bounds.origin.x
|
||||
+ px(cell_width) * cursor.col as f32
|
||||
+ px(cell_width) * range_utf16.start as f32;
|
||||
let y = element_bounds.origin.y + px(line_height) * cursor.row as f32;
|
||||
+ px(self.terminal_cell_width()) * cursor.col as f32
|
||||
+ px(self.terminal_cell_width()) * range_utf16.start as f32;
|
||||
let y = element_bounds.origin.y + px(self.terminal_line_height()) * cursor.row as f32;
|
||||
Some(Bounds::new(
|
||||
point(x, y),
|
||||
size(
|
||||
px(cell_width),
|
||||
px(line_height),
|
||||
px(self.terminal_cell_width()),
|
||||
px(self.terminal_line_height()),
|
||||
),
|
||||
))
|
||||
}
|
||||
@@ -2818,7 +2807,7 @@ impl Ashell {
|
||||
) {
|
||||
self.focus_handle.focus(window, cx);
|
||||
if event.button == MouseButton::Left {
|
||||
self.begin_terminal_selection(event, window, cx);
|
||||
self.begin_terminal_selection(event, cx);
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
@@ -2860,7 +2849,7 @@ impl Ashell {
|
||||
}
|
||||
}
|
||||
|
||||
fn begin_terminal_selection(&mut self, event: &MouseDownEvent, window: &Window, cx: &mut Context<Self>) {
|
||||
fn begin_terminal_selection(&mut self, event: &MouseDownEvent, cx: &mut Context<Self>) {
|
||||
let click_count = event.click_count.max(1);
|
||||
let selection_type = match click_count {
|
||||
1 => SelectionType::Simple,
|
||||
@@ -2868,7 +2857,7 @@ impl Ashell {
|
||||
3 => SelectionType::Lines,
|
||||
_ => SelectionType::Simple,
|
||||
};
|
||||
let Some((row, col, side)) = self.terminal_grid_point_and_side(event.position, window) else {
|
||||
let Some((row, col, side)) = self.terminal_grid_point_and_side(event.position) else {
|
||||
return;
|
||||
};
|
||||
let Some(active_id) = self.active_tab.clone() else {
|
||||
@@ -2884,13 +2873,13 @@ impl Ashell {
|
||||
fn on_terminal_mouse_move(
|
||||
&mut self,
|
||||
event: &MouseMoveEvent,
|
||||
window: &mut Window,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if !self.terminal_selecting || event.pressed_button != Some(MouseButton::Left) {
|
||||
return;
|
||||
}
|
||||
let Some((row, col, side)) = self.terminal_grid_point_and_side(event.position, window) else {
|
||||
let Some((row, col, side)) = self.terminal_grid_point_and_side(event.position) else {
|
||||
return;
|
||||
};
|
||||
let Some(active_id) = self.active_tab.clone() else {
|
||||
@@ -2905,7 +2894,7 @@ impl Ashell {
|
||||
fn on_terminal_mouse_up(
|
||||
&mut self,
|
||||
_event: &MouseUpEvent,
|
||||
window: &mut Window,
|
||||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
self.terminal_selecting = false;
|
||||
@@ -2915,7 +2904,6 @@ impl Ashell {
|
||||
fn terminal_grid_point_and_side(
|
||||
&self,
|
||||
position: Point<Pixels>,
|
||||
window: &Window,
|
||||
) -> Option<(usize, usize, Side)> {
|
||||
let bounds = self.terminal_bounds?;
|
||||
if !bounds.contains(&position) {
|
||||
@@ -2923,7 +2911,7 @@ impl Ashell {
|
||||
}
|
||||
let local_x = (position.x - bounds.origin.x).max(px(0.));
|
||||
let local_y = (position.y - bounds.origin.y).max(px(0.));
|
||||
let cell_width = px(self.terminal_cell_width(window));
|
||||
let cell_width = px(self.terminal_cell_width());
|
||||
let line_height = px(self.terminal_line_height());
|
||||
let snapshot = self.active_snapshot()?;
|
||||
let max_col = snapshot.cols.saturating_sub(1);
|
||||
@@ -3096,9 +3084,9 @@ impl Ashell {
|
||||
.map(|size| size.as_f32())
|
||||
.unwrap_or(viewport.height.as_f32() - TAB_BAR_HEIGHT - 248.0);
|
||||
let width = (viewport.width.as_f32() - sidebar_width - TERMINAL_PADDING_X - 8.0)
|
||||
.max(self.terminal_cell_width(window));
|
||||
.max(self.terminal_cell_width());
|
||||
let height = (terminal_height - TERMINAL_PADDING_Y).max(self.terminal_line_height());
|
||||
let cols = (width / self.terminal_cell_width(window)).floor().max(1.0) as u16;
|
||||
let cols = (width / self.terminal_cell_width()).floor().max(1.0) as u16;
|
||||
let rows = (height / self.terminal_line_height()).floor().max(1.0) as u16;
|
||||
|
||||
for tab in &mut self.tabs {
|
||||
@@ -3554,8 +3542,6 @@ impl Ashell {
|
||||
.tab_stop(false)
|
||||
.on_click(cx.listener(|this, checked, _, cx| {
|
||||
this.show_hidden_files = *checked;
|
||||
this.config.set_show_hidden_files(*checked);
|
||||
let _ = this.config.save();
|
||||
cx.notify();
|
||||
})),
|
||||
)
|
||||
@@ -4398,7 +4384,7 @@ impl Render for Ashell {
|
||||
self.terminal_font_family.clone(),
|
||||
px(self.terminal_font_size),
|
||||
px(self.terminal_line_height()),
|
||||
px(self.terminal_cell_width(window)),
|
||||
px(self.terminal_cell_width()),
|
||||
),
|
||||
)
|
||||
.vertical_scrollbar(&self.terminal_scrollbar)
|
||||
|
||||
@@ -144,8 +144,6 @@ pub struct PrepaintState {
|
||||
struct TerminalInputHandler {
|
||||
view: Entity<Ashell>,
|
||||
element_bounds: Bounds<Pixels>,
|
||||
cell_width: f32,
|
||||
line_height: f32,
|
||||
}
|
||||
|
||||
impl InputHandler for TerminalInputHandler {
|
||||
@@ -221,7 +219,7 @@ impl InputHandler for TerminalInputHandler {
|
||||
) -> Option<Bounds<Pixels>> {
|
||||
self.view
|
||||
.read(cx)
|
||||
.terminal_ime_bounds_for_range(range_utf16, self.element_bounds, self.cell_width, self.line_height)
|
||||
.terminal_ime_bounds_for_range(range_utf16, self.element_bounds)
|
||||
}
|
||||
|
||||
fn character_index_for_point(
|
||||
@@ -494,8 +492,6 @@ impl Element for TerminalElement {
|
||||
TerminalInputHandler {
|
||||
view: self.view.clone(),
|
||||
element_bounds: prepaint.bounds,
|
||||
cell_width: prepaint.metrics.cell_width.as_f32(),
|
||||
line_height: prepaint.metrics.line_height.as_f32(),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user