input: Adjust blink cursor height. (#1704)
This commit is contained in:
parent
6505be409b
commit
df9655e80a
4 changed files with 17 additions and 8 deletions
|
|
@ -1,20 +1,20 @@
|
|||
use std::{ops::Range, rc::Rc};
|
||||
|
||||
use gpui::{
|
||||
fill, point, px, relative, size, App, Bounds, Corners, Element, ElementId, ElementInputHandler,
|
||||
Entity, GlobalElementId, Half, HighlightStyle, Hitbox, Hsla, IntoElement, LayoutId,
|
||||
MouseButton, MouseMoveEvent, Path, Pixels, Point, ShapedLine, SharedString, Size, Style,
|
||||
TextRun, TextStyle, UnderlineStyle, Window,
|
||||
App, Bounds, Corners, Element, ElementId, ElementInputHandler, Entity, GlobalElementId, Half,
|
||||
HighlightStyle, Hitbox, Hsla, IntoElement, LayoutId, MouseButton, MouseMoveEvent, Path, Pixels,
|
||||
Point, ShapedLine, SharedString, Size, Style, TextRun, TextStyle, UnderlineStyle, Window, fill,
|
||||
point, px, relative, size,
|
||||
};
|
||||
use ropey::Rope;
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::{
|
||||
input::{blink_cursor::CURSOR_WIDTH, text_wrapper::LineLayout, RopeExt as _},
|
||||
ActiveTheme as _, Colorize, PixelsExt, Root,
|
||||
input::{RopeExt as _, blink_cursor::CURSOR_WIDTH, text_wrapper::LineLayout},
|
||||
};
|
||||
|
||||
use super::{mode::InputMode, InputState, LastLayout};
|
||||
use super::{InputState, LastLayout, mode::InputMode};
|
||||
|
||||
const BOTTOM_MARGIN_ROWS: usize = 3;
|
||||
pub(super) const RIGHT_MARGIN: Pixels = px(10.);
|
||||
|
|
@ -222,7 +222,12 @@ impl TextElement {
|
|||
}
|
||||
|
||||
// cursor bounds
|
||||
let cursor_height = line_height;
|
||||
let cursor_height = match state.size {
|
||||
crate::Size::Large => 1.,
|
||||
crate::Size::Small => 0.75,
|
||||
_ => 0.85,
|
||||
} * line_height;
|
||||
|
||||
cursor_bounds = Some(Bounds::new(
|
||||
point(
|
||||
bounds.left() + cursor_pos.x + line_number_width + scroll_offset.x,
|
||||
|
|
|
|||
|
|
@ -252,6 +252,7 @@ impl RenderOnce for Input {
|
|||
state.text_wrapper.set_font(font, font_size, cx);
|
||||
state.text_wrapper.prepare_if_need(&state.text, cx);
|
||||
state.disabled = self.disabled;
|
||||
state.size = self.size;
|
||||
});
|
||||
|
||||
let state = self.state.read(cx);
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use super::{
|
|||
TabSize, blink_cursor::BlinkCursor, change::Change, element::TextElement,
|
||||
mask_pattern::MaskPattern, mode::InputMode, number_input, text_wrapper::TextWrapper,
|
||||
};
|
||||
use crate::Size;
|
||||
use crate::actions::{SelectDown, SelectLeft, SelectRight, SelectUp};
|
||||
use crate::input::movement::MoveDirection;
|
||||
use crate::input::{
|
||||
|
|
@ -286,6 +287,7 @@ pub struct InputState {
|
|||
pub(super) last_bounds: Option<Bounds<Pixels>>,
|
||||
pub(super) last_selected_range: Option<Selection>,
|
||||
pub(super) selecting: bool,
|
||||
pub(super) size: Size,
|
||||
pub(super) disabled: bool,
|
||||
pub(super) masked: bool,
|
||||
pub(super) clean_on_escape: bool,
|
||||
|
|
@ -408,6 +410,7 @@ impl InputState {
|
|||
hover_popover: None,
|
||||
hover_definition: HoverDefinition::default(),
|
||||
silent_replace_text: false,
|
||||
size: Size::default(),
|
||||
_subscriptions,
|
||||
_context_menu_task: Task::ready(Ok(())),
|
||||
_pending_update: false,
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ impl Size {
|
|||
match self {
|
||||
Self::Large => px(16.),
|
||||
Self::Medium => px(12.),
|
||||
Self::Small => px(6.),
|
||||
Self::Small => px(8.),
|
||||
Self::XSmall => px(4.),
|
||||
_ => px(8.),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue