Merge branch 'master' of https://github.com/pop-os/cosmic-term
This commit is contained in:
commit
4cec08875f
8 changed files with 183 additions and 217 deletions
|
|
@ -172,10 +172,9 @@ where
|
|||
// Calculate layout lines
|
||||
terminal.with_buffer(|buffer| {
|
||||
let mut layout_lines = 0;
|
||||
for line in buffer.lines.iter() {
|
||||
match line.layout_opt() {
|
||||
Some(layout) => layout_lines += layout.len(),
|
||||
None => (),
|
||||
for line in &buffer.lines {
|
||||
if let Some(layout) = line.layout_opt() {
|
||||
layout_lines += layout.len()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +240,7 @@ where
|
|||
let state = tree.state.downcast_ref::<State>();
|
||||
|
||||
let cosmic_theme = theme.cosmic();
|
||||
let scrollbar_w = cosmic_theme.spacing.space_xxs as f32;
|
||||
let scrollbar_w = f32::from(cosmic_theme.spacing.space_xxs);
|
||||
|
||||
let view_position = layout.position() + [self.padding.left, self.padding.top].into();
|
||||
let view_w = cmp::min(viewport.width as i32, layout.bounds().width as i32)
|
||||
|
|
@ -278,12 +277,12 @@ where
|
|||
..Default::default()
|
||||
},
|
||||
Color::new(
|
||||
background_color.r() as f32 / 255.0,
|
||||
background_color.g() as f32 / 255.0,
|
||||
background_color.b() as f32 / 255.0,
|
||||
f32::from(background_color.r()) / 255.0,
|
||||
f32::from(background_color.g()) / 255.0,
|
||||
f32::from(background_color.b()) / 255.0,
|
||||
match self.opacity {
|
||||
Some(opacity) => opacity,
|
||||
None => background_color.a() as f32 / 255.0,
|
||||
None => f32::from(background_color.a()) / 255.0,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
|
@ -329,10 +328,10 @@ where
|
|||
) {
|
||||
let cosmic_text_to_iced_color = |color: cosmic_text::Color| {
|
||||
Color::new(
|
||||
color.r() as f32 / 255.0,
|
||||
color.g() as f32 / 255.0,
|
||||
color.b() as f32 / 255.0,
|
||||
color.a() as f32 / 255.0,
|
||||
f32::from(color.r()) / 255.0,
|
||||
f32::from(color.g()) / 255.0,
|
||||
f32::from(color.b()) / 255.0,
|
||||
f32::from(color.a()) / 255.0,
|
||||
)
|
||||
};
|
||||
|
||||
|
|
@ -370,8 +369,7 @@ where
|
|||
}
|
||||
|
||||
if !metadata.flags.is_empty() {
|
||||
let style_line_height =
|
||||
(self.glyph_font_size / 10.0).max(2.0).min(16.0);
|
||||
let style_line_height = (self.glyph_font_size / 10.0).clamp(2.0, 16.0);
|
||||
|
||||
let line_color = cosmic_text_to_iced_color(metadata.underline_color);
|
||||
|
||||
|
|
@ -488,7 +486,7 @@ where
|
|||
view_position,
|
||||
metadata_set,
|
||||
};
|
||||
for glyph in run.glyphs.iter() {
|
||||
for glyph in run.glyphs {
|
||||
bg_rect.update(glyph, renderer, state.is_focused);
|
||||
}
|
||||
bg_rect.fill(renderer, state.is_focused);
|
||||
|
|
@ -606,7 +604,7 @@ where
|
|||
modifiers,
|
||||
..
|
||||
}) if state.is_focused => {
|
||||
for (key_bind, _) in self.key_binds.iter() {
|
||||
for key_bind in self.key_binds.keys() {
|
||||
if key_bind.matches(modifiers, &Key::Named(named)) {
|
||||
return Status::Captured;
|
||||
}
|
||||
|
|
@ -705,8 +703,7 @@ where
|
|||
match named {
|
||||
Named::Backspace => {
|
||||
let code = if modifiers.control() { "\x08" } else { "\x7f" };
|
||||
terminal
|
||||
.input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec());
|
||||
terminal.input_scroll(format!("{alt_prefix}{code}").as_bytes().to_vec());
|
||||
status = Status::Captured;
|
||||
}
|
||||
Named::Enter => {
|
||||
|
|
@ -735,8 +732,7 @@ where
|
|||
}
|
||||
Named::Tab => {
|
||||
let code = if modifiers.shift() { "\x1b[Z" } else { "\x09" };
|
||||
terminal
|
||||
.input_scroll(format!("{}{}", alt_prefix, code).as_bytes().to_vec());
|
||||
terminal.input_scroll(format!("{alt_prefix}{code}").as_bytes().to_vec());
|
||||
status = Status::Captured;
|
||||
}
|
||||
_ => {}
|
||||
|
|
@ -751,7 +747,7 @@ where
|
|||
key,
|
||||
..
|
||||
}) if state.is_focused => {
|
||||
for (key_bind, _) in self.key_binds.iter() {
|
||||
for key_bind in self.key_binds.keys() {
|
||||
if key_bind.matches(modifiers, &key) {
|
||||
return Status::Captured;
|
||||
}
|
||||
|
|
@ -1064,9 +1060,9 @@ fn shade(color: cosmic_text::Color, is_focused: bool) -> cosmic_text::Color {
|
|||
} else {
|
||||
let shade = 0.92;
|
||||
cosmic_text::Color::rgba(
|
||||
(color.r() as f32 * shade) as u8,
|
||||
(color.g() as f32 * shade) as u8,
|
||||
(color.b() as f32 * shade) as u8,
|
||||
(f32::from(color.r()) * shade) as u8,
|
||||
(f32::from(color.g()) * shade) as u8,
|
||||
(f32::from(color.b()) * shade) as u8,
|
||||
color.a(),
|
||||
)
|
||||
}
|
||||
|
|
@ -1106,8 +1102,8 @@ pub struct State {
|
|||
|
||||
impl State {
|
||||
/// Creates a new [`State`].
|
||||
pub fn new() -> State {
|
||||
State {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
modifiers: Modifiers::empty(),
|
||||
click: None,
|
||||
dragging: None,
|
||||
|
|
@ -1142,7 +1138,7 @@ meta 0b100000 (32)
|
|||
caps_lock 0b1000000 (64)
|
||||
num_lock 0b10000000 (128)
|
||||
*/
|
||||
fn calculate_modifier_number(state: &mut State) -> u8 {
|
||||
fn calculate_modifier_number(state: &State) -> u8 {
|
||||
let mut mod_no = 0;
|
||||
if state.modifiers.shift() {
|
||||
mod_no |= 1;
|
||||
|
|
@ -1162,10 +1158,10 @@ fn calculate_modifier_number(state: &mut State) -> u8 {
|
|||
#[inline(always)]
|
||||
fn csi(code: &str, suffix: &str, modifiers: u8) -> Option<Vec<u8>> {
|
||||
if modifiers == 1 {
|
||||
Some(format!("\x1B[{}{}", code, suffix).as_bytes().to_vec())
|
||||
Some(format!("\x1B[{code}{suffix}").as_bytes().to_vec())
|
||||
} else {
|
||||
Some(
|
||||
format!("\x1B[{};{}{}", code, modifiers, suffix)
|
||||
format!("\x1B[{code};{modifiers}{suffix}")
|
||||
.as_bytes()
|
||||
.to_vec(),
|
||||
)
|
||||
|
|
@ -1175,8 +1171,8 @@ fn csi(code: &str, suffix: &str, modifiers: u8) -> Option<Vec<u8>> {
|
|||
#[inline(always)]
|
||||
fn ss3(code: &str, modifiers: u8) -> Option<Vec<u8>> {
|
||||
if modifiers == 1 {
|
||||
Some(format!("\x1B\x4F{}", code).as_bytes().to_vec())
|
||||
Some(format!("\x1B\x4F{code}").as_bytes().to_vec())
|
||||
} else {
|
||||
Some(format!("\x1B[1;{}{}", modifiers, code).as_bytes().to_vec())
|
||||
Some(format!("\x1B[1;{modifiers}{code}").as_bytes().to_vec())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue