diff --git a/editor/src/editor/ed_error.rs b/editor/src/editor/ed_error.rs index 02da4961b5..e9b8ce15e6 100644 --- a/editor/src/editor/ed_error.rs +++ b/editor/src/editor/ed_error.rs @@ -59,13 +59,13 @@ pub fn print_err(err: &EdError) { } } -pub fn print_ui_err(err: &UIError) { - eprintln!("{}", format!("{}", err).truecolor(255, 0, 0)); +// pub fn print_ui_err(err: &UIError) { +// eprintln!("{}", format!("{}", err).truecolor(255, 0, 0)); - if let Some(backtrace) = ErrorCompat::backtrace(err) { - eprintln!("{}", color_backtrace(backtrace)); - } -} +// if let Some(backtrace) = ErrorCompat::backtrace(err) { +// eprintln!("{}", color_backtrace(backtrace)); +// } +// } fn color_backtrace(backtrace: &snafu::Backtrace) -> String { let backtrace_str = format!("{}", backtrace); diff --git a/editor/src/editor/main.rs b/editor/src/editor/main.rs index 62b032a9df..fd61f79288 100644 --- a/editor/src/editor/main.rs +++ b/editor/src/editor/main.rs @@ -1,7 +1,7 @@ use super::keyboard_input; use crate::editor::{ config::Config, - ed_error::{print_err, print_ui_err}, + ed_error::{print_err}, mvc::{app_model::AppModel, app_update, ed_model}, theme::EdTheme, }; @@ -14,7 +14,6 @@ use crate::graphics::{ primitives::rect::Rect, style::CODE_TXT_XY, }; -use crate::ui::{text::text_pos::TextPos, ui_error::UIResult}; use crate::editor::resources::strings::NOTHING_OPENED; use super::util::slice_get; use crate::lang::{pool::Pool}; @@ -275,35 +274,26 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box> { let text_and_rects_res = super::render_ast::expr2_to_wgpu( - &mut ed_model.markup_root, + ed_model, &render_ast_arena, - &mut ed_model.module.env, - &ed_model.module.ast_root, &size, CODE_TXT_XY.into(), &config, - ed_model.glyph_dim_rect_opt.unwrap() // TODO remove unwrap() ); match text_and_rects_res { Ok((text_section, rects)) => { - + glyph_brush.queue(text_section); - match draw_all_rects( + draw_all_rects( &rects, &mut encoder, &frame.view, &gpu_device, &rect_resources, &ed_theme, - ) { - Ok(()) => (), - Err(e) => { - print_ui_err(&e); - begin_render_pass(&mut encoder, &frame.view, &ed_theme); - } - } + ) }, Err(e) => print_err(&e) } @@ -345,13 +335,13 @@ fn run_event_loop(file_path_opt: Option<&Path>) -> Result<(), Box> { } fn draw_all_rects( - all_rects: &Vec, + all_rects: &[Rect], encoder: &mut CommandEncoder, texture_view: &TextureView, gpu_device: &wgpu::Device, rect_resources: &RectResources, ed_theme: &EdTheme, -) -> UIResult<()> { +) { let rect_buffers = create_rect_buffers(gpu_device, encoder, all_rects); // block necessary for borrowing encoder @@ -369,8 +359,6 @@ fn draw_all_rects( } begin_render_pass(encoder, texture_view, ed_theme); - - Ok(()) } fn begin_render_pass<'a>( @@ -394,40 +382,40 @@ fn begin_render_pass<'a>( }) } -fn queue_editor_text( - size: &PhysicalSize, - editor_lines: &str, - caret_pos: TextPos, - config: &Config, - glyph_brush: &mut GlyphBrush<()>, -) { - let area_bounds = (size.width as f32, size.height as f32).into(); +// fn queue_editor_text( +// size: &PhysicalSize, +// editor_lines: &str, +// caret_pos: TextPos, +// config: &Config, +// glyph_brush: &mut GlyphBrush<()>, +// ) { +// let area_bounds = (size.width as f32, size.height as f32).into(); - let code_text = Text { - position: CODE_TXT_XY.into(), - area_bounds, - text: editor_lines, - size: config.code_font_size, - ..Default::default() - }; +// let code_text = Text { +// position: CODE_TXT_XY.into(), +// area_bounds, +// text: editor_lines, +// size: config.code_font_size, +// ..Default::default() +// }; - let s = format!("Ln {}, Col {}", caret_pos.line, caret_pos.column); - let text = s.as_str(); +// let s = format!("Ln {}, Col {}", caret_pos.line, caret_pos.column); +// let text = s.as_str(); - let caret_pos_label = Text { - position: ((size.width as f32) - 150.0, (size.height as f32) - 40.0).into(), - area_bounds, - color: config.ed_theme.ui_theme.text, - text, - size: 25.0, - ..Default::default() - }; +// let caret_pos_label = Text { +// position: ((size.width as f32) - 150.0, (size.height as f32) - 40.0).into(), +// area_bounds, +// color: config.ed_theme.ui_theme.text, +// text, +// size: 25.0, +// ..Default::default() +// }; - queue_text_draw(&caret_pos_label, glyph_brush); +// queue_text_draw(&caret_pos_label, glyph_brush); - // TODO convert to ast and render with render_ast::render_expr2 - queue_text_draw(&code_text, glyph_brush); -} +// // TODO convert to ast and render with render_ast::render_expr2 +// queue_text_draw(&code_text, glyph_brush); +// } fn queue_no_file_text( size: &PhysicalSize, diff --git a/editor/src/editor/markup.rs b/editor/src/editor/markup.rs index 8eecd68a37..028bd13dcf 100644 --- a/editor/src/editor/markup.rs +++ b/editor/src/editor/markup.rs @@ -1,4 +1,4 @@ - +#![allow(dead_code)] use super::syntax_highlight::HighlightStyle; use bumpalo::Bump; @@ -25,6 +25,7 @@ pub enum MarkupNode { } } + #[derive(Debug)] pub enum Attribute { Caret { diff --git a/editor/src/editor/mvc/app_model.rs b/editor/src/editor/mvc/app_model.rs index 55f808b232..e774259191 100644 --- a/editor/src/editor/mvc/app_model.rs +++ b/editor/src/editor/mvc/app_model.rs @@ -1,3 +1,6 @@ + +#![allow(dead_code)] + use super::ed_model::EdModel; use crate::editor::ed_error::{ print_err, diff --git a/editor/src/editor/render_ast.rs b/editor/src/editor/render_ast.rs index 6f7a4d1360..8042fa4d32 100644 --- a/editor/src/editor/render_ast.rs +++ b/editor/src/editor/render_ast.rs @@ -4,6 +4,7 @@ use crate::editor::{ util::map_get, }; use super::markup::{MarkupNode, expr2_to_markup}; +use super::mvc::ed_model::EdModel; use crate::graphics::colors::RgbaTup; use crate::graphics::primitives::text as gr_text; use crate::graphics::primitives::rect::Rect; @@ -11,26 +12,26 @@ use bumpalo::Bump; use cgmath::Vector2; use std::collections::HashMap; use winit::dpi::PhysicalSize; +use snafu::OptionExt; +use crate::ui::ui_error::{MissingGlyphDims}; use crate::{ editor::config::Config, graphics::colors, - lang::{ast::Expr2, expr::Env}, }; pub fn expr2_to_wgpu<'a>( - markup_root: &'a mut MarkupNode, + ed_model: &'a mut EdModel, arena: &'a Bump, - env: &mut Env<'a>, - expr2: &Expr2, size: &PhysicalSize, position: Vector2, config: &Config, - glyph_dim_rect: Rect, ) -> EdResult<(wgpu_glyph::Section<'a>, Vec)> { - *markup_root = expr2_to_markup(arena, env, expr2); + ed_model.markup_root = expr2_to_markup(arena, &mut ed_model.module.env, &ed_model.module.ast_root); + + let glyph_dim_rect = ed_model.glyph_dim_rect_opt.context(MissingGlyphDims {})?; - build_code_graphics(markup_root, size, position, config, glyph_dim_rect) + build_code_graphics(&ed_model.markup_root, size, position, config, glyph_dim_rect) } pub fn build_code_graphics<'a>( @@ -109,8 +110,8 @@ fn markup_to_wgpu_helper<'a>( let hole_rect = Rect { top_left_coords: ((*text_row as f32) * glyph_dim_rect.height, (*text_col as f32) * glyph_dim_rect.width).into(), - width: glyph_dim_rect.width, - height: glyph_dim_rect.height, + width: glyph_dim_rect.width * 10.0, + height: glyph_dim_rect.height * 10.0, color: colors::WHITE, }; rects.push(hole_rect); diff --git a/editor/src/graphics/lowlevel/buffer.rs b/editor/src/graphics/lowlevel/buffer.rs index 3b493ae33c..b7f8948c8d 100644 --- a/editor/src/graphics/lowlevel/buffer.rs +++ b/editor/src/graphics/lowlevel/buffer.rs @@ -95,7 +95,7 @@ pub struct RectBuffers { pub fn create_rect_buffers( gpu_device: &wgpu::Device, encoder: &mut wgpu::CommandEncoder, - rects: &Vec, + rects: &[Rect], ) -> RectBuffers { let nr_of_rects = rects.len() as u64; diff --git a/editor/src/ui/text/big_selectable_text.rs b/editor/src/ui/text/big_selectable_text.rs index b39ce009a0..5b37e06886 100644 --- a/editor/src/ui/text/big_selectable_text.rs +++ b/editor/src/ui/text/big_selectable_text.rs @@ -1,5 +1,7 @@ // Adapted from https://github.com/cessen/ropey by Nathan Vegdahl, licensed under the MIT license +#![allow(dead_code)] + use crate::ui::text::{ caret_w_select::CaretWSelect, lines::{Lines, MutSelectableLines, SelectableLines}, diff --git a/editor/src/ui/text/caret_w_select.rs b/editor/src/ui/text/caret_w_select.rs index 6668e7d462..8eb2790486 100644 --- a/editor/src/ui/text/caret_w_select.rs +++ b/editor/src/ui/text/caret_w_select.rs @@ -1,3 +1,6 @@ + +#![allow(dead_code)] + use super::selection::validate_selection; use super::selection::Selection; use super::text_pos::TextPos; diff --git a/editor/src/ui/text/selection.rs b/editor/src/ui/text/selection.rs index a67eea03e1..3eb0c2ca97 100644 --- a/editor/src/ui/text/selection.rs +++ b/editor/src/ui/text/selection.rs @@ -1,3 +1,6 @@ + +#![allow(dead_code)] + use super::lines::Lines; use super::text_pos::TextPos; use crate::ui::theme::UITheme;