Skip to content

Commit

Permalink
Merge branch 'main' into new-keyboard-v3
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.lock
  • Loading branch information
last-partizan committed Jun 11, 2023
2 parents aa637e0 + ed58c49 commit b72807e
Show file tree
Hide file tree
Showing 23 changed files with 991 additions and 281 deletions.
535 changes: 323 additions & 212 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ members = ["neovide-derive"]
[features]
default = []
embed-fonts = []
profiling = ["dep:tracy-client-sys"]
gpu_profiling = ["profiling"]

[dependencies]
async-trait = "0.1.53"
Expand All @@ -22,7 +24,7 @@ clap = { version = "4.0.8", features = ["cargo", "derive", "env"] }
copypasta = "0.8.1"
csscolorparser = "0.6.2"
derive-new = "0.5.9"
dirs = "4.0.0"
dirs = "5.0.0"
euclid = "0.22.7"
flexi_logger = { version = "0.22.3", default-features = false }
futures = "0.3.21"
Expand All @@ -47,6 +49,8 @@ swash = "0.1.8"
time = "0.3.9"
tokio = { version = "1.25.0", features = ["full"] }
tokio-util = { version = "0.7.4", features = ["compat"] }
toml = "0.7.3"
tracy-client-sys = { version = "0.19.0", optional = true }
unicode-segmentation = "1.9.0"
which = "4.2.5"
winit = { version = "=0.28.6", features = ["serde"] }
Expand Down Expand Up @@ -81,6 +85,11 @@ lto = true
incremental = true
strip = true

[profile.profiling]
inherits = "release"
strip = false
debug = true

[package.metadata.bundle]
name = "Neovide"
identifier = "com.neovide.neovide"
Expand Down
85 changes: 47 additions & 38 deletions src/bridge/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -835,50 +835,59 @@ pub fn parse_redraw_event(event_value: Value) -> Result<Vec<RedrawEvent>> {

for event in events {
let event_parameters = parse_array(event)?;
let event_parameters_copy = event_parameters.clone();
let possible_parsed_event = match event_name.as_str() {
"set_title" => Some(parse_set_title(event_parameters)?),
"set_title" => Some(parse_set_title(event_parameters)),
"set_icon" => None, // Ignore set icon for now
"mode_info_set" => Some(parse_mode_info_set(event_parameters)?),
"option_set" => Some(parse_option_set(event_parameters)?),
"mode_change" => Some(parse_mode_change(event_parameters)?),
"mouse_on" => Some(RedrawEvent::MouseOn),
"mouse_off" => Some(RedrawEvent::MouseOff),
"busy_start" => Some(RedrawEvent::BusyStart),
"busy_stop" => Some(RedrawEvent::BusyStop),
"flush" => Some(RedrawEvent::Flush),
"grid_resize" => Some(parse_grid_resize(event_parameters)?),
"default_colors_set" => Some(parse_default_colors(event_parameters)?),
"hl_attr_define" => Some(parse_hl_attr_define(event_parameters)?),
"grid_line" => Some(parse_grid_line(event_parameters)?),
"grid_clear" => Some(parse_grid_clear(event_parameters)?),
"grid_destroy" => Some(parse_grid_destroy(event_parameters)?),
"grid_cursor_goto" => Some(parse_grid_cursor_goto(event_parameters)?),
"grid_scroll" => Some(parse_grid_scroll(event_parameters)?),
"win_pos" => Some(parse_win_pos(event_parameters)?),
"win_float_pos" => Some(parse_win_float_pos(event_parameters)?),
"win_external_pos" => Some(parse_win_external_pos(event_parameters)?),
"win_hide" => Some(parse_win_hide(event_parameters)?),
"win_close" => Some(parse_win_close(event_parameters)?),
"msg_set_pos" => Some(parse_msg_set_pos(event_parameters)?),
"win_viewport" => Some(parse_win_viewport(event_parameters)?),
"cmdline_show" => Some(parse_cmdline_show(event_parameters)?),
"cmdline_pos" => Some(parse_cmdline_pos(event_parameters)?),
"cmdline_special_char" => Some(parse_cmdline_special_char(event_parameters)?),
"cmdline_hide" => Some(RedrawEvent::CommandLineHide),
"cmdline_block_show" => Some(parse_cmdline_block_show(event_parameters)?),
"cmdline_block_append" => Some(parse_cmdline_block_append(event_parameters)?),
"cmdline_block_hide" => Some(RedrawEvent::CommandLineBlockHide),
"msg_show" => Some(parse_msg_show(event_parameters)?),
"msg_clear" => Some(RedrawEvent::MessageClear),
"msg_showmode" => Some(parse_msg_showmode(event_parameters)?),
"msg_showcmd" => Some(parse_msg_showcmd(event_parameters)?),
"msg_ruler" => Some(parse_msg_ruler(event_parameters)?),
"msg_history_show" => Some(parse_msg_history_show(event_parameters)?),
"mode_info_set" => Some(parse_mode_info_set(event_parameters)),
"option_set" => Some(parse_option_set(event_parameters)),
"mode_change" => Some(parse_mode_change(event_parameters)),
"mouse_on" => Some(Ok(RedrawEvent::MouseOn)),
"mouse_off" => Some(Ok(RedrawEvent::MouseOff)),
"busy_start" => Some(Ok(RedrawEvent::BusyStart)),
"busy_stop" => Some(Ok(RedrawEvent::BusyStop)),
"flush" => Some(Ok(RedrawEvent::Flush)),
"grid_resize" => Some(parse_grid_resize(event_parameters)),
"default_colors_set" => Some(parse_default_colors(event_parameters)),
"hl_attr_define" => Some(parse_hl_attr_define(event_parameters)),
"grid_line" => Some(parse_grid_line(event_parameters)),
"grid_clear" => Some(parse_grid_clear(event_parameters)),
"grid_destroy" => Some(parse_grid_destroy(event_parameters)),
"grid_cursor_goto" => Some(parse_grid_cursor_goto(event_parameters)),
"grid_scroll" => Some(parse_grid_scroll(event_parameters)),
"win_pos" => Some(parse_win_pos(event_parameters)),
"win_float_pos" => Some(parse_win_float_pos(event_parameters)),
"win_external_pos" => Some(parse_win_external_pos(event_parameters)),
"win_hide" => Some(parse_win_hide(event_parameters)),
"win_close" => Some(parse_win_close(event_parameters)),
"msg_set_pos" => Some(parse_msg_set_pos(event_parameters)),
"win_viewport" => Some(parse_win_viewport(event_parameters)),
"cmdline_show" => Some(parse_cmdline_show(event_parameters)),
"cmdline_pos" => Some(parse_cmdline_pos(event_parameters)),
"cmdline_special_char" => Some(parse_cmdline_special_char(event_parameters)),
"cmdline_hide" => Some(Ok(RedrawEvent::CommandLineHide)),
"cmdline_block_show" => Some(parse_cmdline_block_show(event_parameters)),
"cmdline_block_append" => Some(parse_cmdline_block_append(event_parameters)),
"cmdline_block_hide" => Some(Ok(RedrawEvent::CommandLineBlockHide)),
"msg_show" => Some(parse_msg_show(event_parameters)),
"msg_clear" => Some(Ok(RedrawEvent::MessageClear)),
"msg_showmode" => Some(parse_msg_showmode(event_parameters)),
"msg_showcmd" => Some(parse_msg_showcmd(event_parameters)),
"msg_ruler" => Some(parse_msg_ruler(event_parameters)),
"msg_history_show" => Some(parse_msg_history_show(event_parameters)),
_ => None,
};

if let Some(parsed_event) = possible_parsed_event {
parsed_events.push(parsed_event);
if let Ok(parsed_event) = parsed_event {
parsed_events.push(parsed_event);
} else {
let parser_error = parsed_event.unwrap_err();
let error = ParseError::Format(format!(
"for event '{event_name}' - {event_parameters_copy:?} - {parser_error}"
));
return Err(error);
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cmd_line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub struct CmdLineSettings {
/// Render every frame, takes more power and CPU time but possibly helps with frame timing
/// issues
#[arg(long = "noidle", env = "NEOVIDE_IDLE", action = ArgAction::SetFalse, value_parser = FalseyValueParser::new())]
pub no_idle: bool,
pub idle: bool,

/// Disable opening multiple files supplied in tabs (they're still buffers)
#[arg(long = "notabs")]
Expand Down
82 changes: 65 additions & 17 deletions src/editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use log::{error, trace};
use crate::{
bridge::{GuiOption, RedrawEvent, WindowAnchor},
event_aggregator::EVENT_AGGREGATOR,
profiling::tracy_zone,
redraw_scheduler::REDRAW_SCHEDULER,
renderer::DrawCommand,
window::WindowCommand,
Expand Down Expand Up @@ -81,18 +82,24 @@ impl Editor {
match command {
EditorCommand::NeovimRedrawEvent(event) => match event {
RedrawEvent::SetTitle { title } => {
tracy_zone!("EditorSetTitle");
EVENT_AGGREGATOR.send(WindowCommand::TitleChanged(title));
}
RedrawEvent::ModeInfoSet { cursor_modes } => {
tracy_zone!("EditorModeInfoSet");
self.mode_list = cursor_modes;
if let Some(current_mode_i) = self.current_mode_index {
if let Some(current_mode) = self.mode_list.get(current_mode_i as usize) {
self.cursor.change_mode(current_mode, &self.defined_styles)
}
}
}
RedrawEvent::OptionSet { gui_option } => self.set_option(gui_option),
RedrawEvent::OptionSet { gui_option } => {
tracy_zone!("EditorOptionSet");
self.set_option(gui_option);
}
RedrawEvent::ModeChange { mode, mode_index } => {
tracy_zone!("ModeChange");
if let Some(cursor_mode) = self.mode_list.get(mode_index as usize) {
self.cursor.change_mode(cursor_mode, &self.defined_styles);
self.current_mode_index = Some(mode_index)
Expand All @@ -104,26 +111,38 @@ impl Editor {
.ok();
}
RedrawEvent::MouseOn => {
tracy_zone!("EditorMouseOn");
EVENT_AGGREGATOR.send(WindowCommand::SetMouseEnabled(true));
}
RedrawEvent::MouseOff => {
tracy_zone!("EditorMouseOff");
EVENT_AGGREGATOR.send(WindowCommand::SetMouseEnabled(false));
}
RedrawEvent::BusyStart => {
tracy_zone!("EditorBusyStart");
trace!("Cursor off");
self.cursor.enabled = false;
}
RedrawEvent::BusyStop => {
tracy_zone!("EditorBusyStop");
trace!("Cursor on");
self.cursor.enabled = true;
}
RedrawEvent::Flush => {
tracy_zone!("EditorFlush");
trace!("Image flushed");
self.send_cursor_info();
self.draw_command_batcher.send_batch();
REDRAW_SCHEDULER.queue_next_frame();
{
trace!("send_batch");
self.draw_command_batcher.send_batch();
}
{
trace!("queue_next_frame");
REDRAW_SCHEDULER.queue_next_frame();
}
}
RedrawEvent::DefaultColorsSet { colors } => {
tracy_zone!("EditorDefaultColorsSet");
self.draw_command_batcher
.queue(DrawCommand::DefaultStyleChanged(Style::new(colors)))
.ok();
Expand All @@ -132,18 +151,23 @@ impl Editor {
REDRAW_SCHEDULER.queue_next_frame();
}
RedrawEvent::HighlightAttributesDefine { id, style } => {
tracy_zone!("EditorHighlightAttributesDefine");
self.defined_styles.insert(id, Arc::new(style));
}
RedrawEvent::CursorGoto {
grid,
column: left,
row: top,
} => self.set_cursor_position(grid, left, top),
} => {
tracy_zone!("EditorCursorGoto");
self.set_cursor_position(grid, left, top);
}
RedrawEvent::Resize {
grid,
width,
height,
} => {
tracy_zone!("EditorResize");
self.resize_window(grid, width, height);
}
RedrawEvent::GridLine {
Expand All @@ -152,19 +176,24 @@ impl Editor {
column_start,
cells,
} => {
tracy_zone!("EditorGridLine");
let defined_styles = &self.defined_styles;
let window = self.windows.get_mut(&grid);
if let Some(window) = window {
window.draw_grid_line(row, column_start, cells, defined_styles);
}
}
RedrawEvent::Clear { grid } => {
tracy_zone!("EditorClear");
let window = self.windows.get_mut(&grid);
if let Some(window) = window {
window.clear();
}
}
RedrawEvent::Destroy { grid } => self.close_window(grid),
RedrawEvent::Destroy { grid } => {
tracy_zone!("EditorDestroy");
self.close_window(grid)
}
RedrawEvent::Scroll {
grid,
top,
Expand All @@ -174,6 +203,7 @@ impl Editor {
rows,
columns,
} => {
tracy_zone!("EditorScroll");
let window = self.windows.get_mut(&grid);
if let Some(window) = window {
window.scroll_region(top, bottom, left, right, rows, columns);
Expand All @@ -185,7 +215,10 @@ impl Editor {
start_column,
width,
height,
} => self.set_window_position(grid, start_column, start_row, width, height),
} => {
tracy_zone!("EditorWindowPosition");
self.set_window_position(grid, start_column, start_row, width, height)
}
RedrawEvent::WindowFloatPosition {
grid,
anchor,
Expand All @@ -194,33 +227,47 @@ impl Editor {
anchor_row: anchor_top,
sort_order,
..
} => self.set_window_float_position(
grid,
anchor_grid,
anchor,
anchor_left,
anchor_top,
sort_order,
),
} => {
tracy_zone!("EditorWindowFloatPosition");
self.set_window_float_position(
grid,
anchor_grid,
anchor,
anchor_left,
anchor_top,
sort_order,
)
}
RedrawEvent::WindowHide { grid } => {
tracy_zone!("EditorWindowHide");
let window = self.windows.get(&grid);
if let Some(window) = window {
window.hide();
}
}
RedrawEvent::WindowClose { grid } => self.close_window(grid),
RedrawEvent::WindowClose { grid } => {
tracy_zone!("EditorWindowClose");
self.close_window(grid)
}
RedrawEvent::MessageSetPosition { grid, row, .. } => {
tracy_zone!("EditorMessageSetPosition");
self.set_message_position(grid, row)
}
RedrawEvent::WindowViewport {
grid,
// Don't send viewport events if they don't have a scroll delta
scroll_delta: Some(scroll_delta),
..
} => self.send_updated_viewport(grid, scroll_delta),
} => {
tracy_zone!("EditorWindowViewport");
self.send_updated_viewport(grid, scroll_delta)
}
_ => {}
},
EditorCommand::RedrawScreen => self.redraw_screen(),
EditorCommand::RedrawScreen => {
tracy_zone!("EditorRedrawScreen");
self.redraw_screen();
}
};
}

Expand Down Expand Up @@ -423,6 +470,7 @@ impl Editor {
}

fn send_cursor_info(&mut self) {
tracy_zone!("send_cursor_info");
let (grid_left, grid_top) = self.cursor.grid_position;
if let Some(window) = self.windows.get(&self.cursor.parent_window_id) {
let (character, style, double_width) = window.get_cursor_grid_cell(grid_left, grid_top);
Expand Down
4 changes: 3 additions & 1 deletion src/frame.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
use core::fmt;

use serde::Deserialize;

use clap::{builder::PossibleValue, ValueEnum};

// Options for the frame decorations
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default)]
#[derive(Debug, Clone, Copy, Eq, PartialEq, Default, Deserialize)]
pub enum Frame {
#[default]
Full,
Expand Down
Loading

0 comments on commit b72807e

Please sign in to comment.