mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
editor folder reorganization
This commit is contained in:
parent
c420893fe2
commit
df5661541c
28 changed files with 93 additions and 92 deletions
|
@ -1,8 +1,7 @@
|
||||||
// Adapted from https://github.com/sotrh/learn-wgpu
|
// Adapted from https://github.com/sotrh/learn-wgpu
|
||||||
// by Benjamin Hansen, licensed under the MIT license
|
// by Benjamin Hansen, licensed under the MIT license
|
||||||
use crate::rect::Rect;
|
use crate::graphics::lowlevel::vertex::Vertex;
|
||||||
use crate::util::size_of_slice;
|
use crate::graphics::primitives::rect::Rect;
|
||||||
use crate::vertex::Vertex;
|
|
||||||
use bumpalo::collections::Vec as BumpVec;
|
use bumpalo::collections::Vec as BumpVec;
|
||||||
use wgpu::util::{BufferInitDescriptor, DeviceExt};
|
use wgpu::util::{BufferInitDescriptor, DeviceExt};
|
||||||
|
|
||||||
|
@ -149,3 +148,9 @@ impl StagingBuffer {
|
||||||
encoder.copy_buffer_to_buffer(&self.buffer, 0, other, 0, self.size)
|
encoder.copy_buffer_to_buffer(&self.buffer, 0, other, 0, self.size)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Taken from https://github.com/sotrh/learn-wgpu
|
||||||
|
// by Benjamin Hansen, licensed under the MIT license
|
||||||
|
pub fn size_of_slice<T: Sized>(slice: &[T]) -> usize {
|
||||||
|
std::mem::size_of::<T>() * slice.len()
|
||||||
|
}
|
3
editor/src/graphics/lowlevel/mod.rs
Normal file
3
editor/src/graphics/lowlevel/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub mod buffer;
|
||||||
|
pub mod ortho;
|
||||||
|
pub mod vertex;
|
3
editor/src/graphics/mod.rs
Normal file
3
editor/src/graphics/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
pub mod colors;
|
||||||
|
pub mod lowlevel;
|
||||||
|
pub mod primitives;
|
2
editor/src/graphics/primitives/mod.rs
Normal file
2
editor/src/graphics/primitives/mod.rs
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
pub mod rect;
|
||||||
|
pub mod text;
|
|
@ -1,7 +1,7 @@
|
||||||
// Adapted from https://github.com/sotrh/learn-wgpu
|
// Adapted from https://github.com/sotrh/learn-wgpu
|
||||||
// by Benjamin Hansen, licensed under the MIT license
|
// by Benjamin Hansen, licensed under the MIT license
|
||||||
|
|
||||||
use crate::rect::Rect;
|
use crate::graphics::primitives::rect::Rect;
|
||||||
use ab_glyph::{FontArc, Glyph, InvalidFont};
|
use ab_glyph::{FontArc, Glyph, InvalidFont};
|
||||||
use cgmath::{Vector2, Vector4};
|
use cgmath::{Vector2, Vector4};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
|
@ -108,13 +108,7 @@ pub fn build_glyph_brush(
|
||||||
gpu_device: &wgpu::Device,
|
gpu_device: &wgpu::Device,
|
||||||
render_format: wgpu::TextureFormat,
|
render_format: wgpu::TextureFormat,
|
||||||
) -> Result<GlyphBrush<()>, InvalidFont> {
|
) -> Result<GlyphBrush<()>, InvalidFont> {
|
||||||
let inconsolata = FontArc::try_from_slice(include_bytes!("../Inconsolata-Regular.ttf"))?;
|
let inconsolata = FontArc::try_from_slice(include_bytes!("../../../Inconsolata-Regular.ttf"))?;
|
||||||
|
|
||||||
Ok(GlyphBrushBuilder::using_font(inconsolata).build(&gpu_device, render_format))
|
Ok(GlyphBrushBuilder::using_font(inconsolata).build(&gpu_device, render_format))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn is_newline(char_ref: &char) -> bool {
|
|
||||||
let newline_codes = vec!['\u{d}'];
|
|
||||||
|
|
||||||
newline_codes.contains(char_ref)
|
|
||||||
}
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::pattern::{Pattern2, PatternId};
|
use crate::lang::pattern::{Pattern2, PatternId};
|
||||||
use crate::pool::{NodeId, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::types::{Type2, TypeId};
|
use crate::lang::types::{Type2, TypeId};
|
||||||
use arraystring::{typenum::U30, ArrayString};
|
use arraystring::{typenum::U30, ArrayString};
|
||||||
use roc_can::expr::Recursive;
|
use roc_can::expr::Recursive;
|
||||||
use roc_module::low_level::LowLevel;
|
use roc_module::low_level::LowLevel;
|
||||||
|
@ -298,7 +298,7 @@ pub type ExprId = NodeId<Expr2>;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn size_of_expr() {
|
fn size_of_expr() {
|
||||||
assert_eq!(std::mem::size_of::<Expr2>(), crate::pool::NODE_BYTES);
|
assert_eq!(std::mem::size_of::<Expr2>(), crate::lang::pool::NODE_BYTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ShallowClone for Rigids {
|
impl ShallowClone for Rigids {
|
|
@ -12,15 +12,15 @@
|
||||||
// };
|
// };
|
||||||
// use crate::pattern::{bindings_from_patterns, canonicalize_pattern, Pattern};
|
// use crate::pattern::{bindings_from_patterns, canonicalize_pattern, Pattern};
|
||||||
// use crate::procedure::References;
|
// use crate::procedure::References;
|
||||||
use crate::ast::{Expr2, FunctionDef, Rigids, ValueDef};
|
use crate::lang::ast::{Expr2, FunctionDef, Rigids, ValueDef};
|
||||||
use crate::expr::Output;
|
use crate::lang::expr::Output;
|
||||||
use crate::expr::{to_expr2, to_expr_id, Env};
|
use crate::lang::expr::{to_expr2, to_expr_id, Env};
|
||||||
use crate::pattern::{
|
use crate::lang::pattern::{
|
||||||
symbols_and_variables_from_pattern, symbols_from_pattern, to_pattern_id, Pattern2, PatternId,
|
symbols_and_variables_from_pattern, symbols_from_pattern, to_pattern_id, Pattern2, PatternId,
|
||||||
};
|
};
|
||||||
use crate::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::scope::Scope;
|
use crate::lang::scope::Scope;
|
||||||
use crate::types::{to_annotation2, Alias, Annotation2, Signature, Type2, TypeId};
|
use crate::lang::types::{to_annotation2, Alias, Annotation2, Signature, Type2, TypeId};
|
||||||
use roc_collections::all::{default_hasher, ImMap, MutMap, MutSet, SendMap};
|
use roc_collections::all::{default_hasher, ImMap, MutMap, MutSet, SendMap};
|
||||||
use roc_module::ident::Lowercase;
|
use roc_module::ident::Lowercase;
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
||||||
|
@ -35,10 +35,7 @@ use ven_graph::{strongly_connected_components, topological_sort_into_groups};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum Def {
|
pub enum Def {
|
||||||
AnnotationOnly {
|
AnnotationOnly { rigids: Rigids, annotation: TypeId },
|
||||||
rigids: crate::ast::Rigids,
|
|
||||||
annotation: TypeId,
|
|
||||||
},
|
|
||||||
Value(ValueDef),
|
Value(ValueDef),
|
||||||
Function(FunctionDef),
|
Function(FunctionDef),
|
||||||
}
|
}
|
||||||
|
@ -127,7 +124,7 @@ fn to_pending_def<'a>(
|
||||||
match def {
|
match def {
|
||||||
Annotation(loc_pattern, loc_ann) => {
|
Annotation(loc_pattern, loc_ann) => {
|
||||||
// This takes care of checking for shadowing and adding idents to scope.
|
// This takes care of checking for shadowing and adding idents to scope.
|
||||||
let (output, loc_can_pattern) = crate::pattern::to_pattern_id(
|
let (output, loc_can_pattern) = crate::lang::pattern::to_pattern_id(
|
||||||
env,
|
env,
|
||||||
scope,
|
scope,
|
||||||
pattern_type,
|
pattern_type,
|
||||||
|
@ -142,7 +139,7 @@ fn to_pending_def<'a>(
|
||||||
}
|
}
|
||||||
Body(loc_pattern, loc_expr) => {
|
Body(loc_pattern, loc_expr) => {
|
||||||
// This takes care of checking for shadowing and adding idents to scope.
|
// This takes care of checking for shadowing and adding idents to scope.
|
||||||
let (output, loc_can_pattern) = crate::pattern::to_pattern_id(
|
let (output, loc_can_pattern) = crate::lang::pattern::to_pattern_id(
|
||||||
env,
|
env,
|
||||||
scope,
|
scope,
|
||||||
pattern_type,
|
pattern_type,
|
|
@ -1,12 +1,12 @@
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
use crate::ast::{Expr2, ExprId, FloatVal, IntStyle, IntVal};
|
use crate::lang::ast::{ClosureExtra, Expr2, ExprId, FloatVal, IntStyle, IntVal, WhenBranch};
|
||||||
use crate::def::References;
|
use crate::lang::def::References;
|
||||||
use crate::pattern::to_pattern2;
|
use crate::lang::pattern::to_pattern2;
|
||||||
use crate::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::scope::Scope;
|
use crate::lang::scope::Scope;
|
||||||
use crate::types::{Type2, TypeId};
|
use crate::lang::types::{Alias, Type2, TypeId};
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use inlinable_string::InlinableString;
|
use inlinable_string::InlinableString;
|
||||||
use roc_can::expr::Recursive;
|
use roc_can::expr::Recursive;
|
||||||
|
@ -22,9 +22,9 @@ use roc_types::subs::{VarStore, Variable};
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq)]
|
#[derive(Clone, Default, Debug, PartialEq)]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
pub references: crate::def::References,
|
pub references: References,
|
||||||
pub tail_call: Option<Symbol>,
|
pub tail_call: Option<Symbol>,
|
||||||
pub aliases: MutMap<Symbol, NodeId<crate::types::Alias>>,
|
pub aliases: MutMap<Symbol, NodeId<Alias>>,
|
||||||
pub non_closures: MutSet<Symbol>,
|
pub non_closures: MutSet<Symbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ pub fn to_expr_id<'a>(
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
parse_expr: &'a roc_parse::ast::Expr<'a>,
|
parse_expr: &'a roc_parse::ast::Expr<'a>,
|
||||||
region: Region,
|
region: Region,
|
||||||
) -> (crate::ast::ExprId, Output) {
|
) -> (ExprId, Output) {
|
||||||
let (expr, output) = to_expr2(env, scope, parse_expr, region);
|
let (expr, output) = to_expr2(env, scope, parse_expr, region);
|
||||||
|
|
||||||
(env.add(expr, region), output)
|
(env.add(expr, region), output)
|
||||||
|
@ -227,7 +227,7 @@ pub fn to_expr2<'a>(
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
parse_expr: &'a roc_parse::ast::Expr<'a>,
|
parse_expr: &'a roc_parse::ast::Expr<'a>,
|
||||||
region: Region,
|
region: Region,
|
||||||
) -> (crate::ast::Expr2, self::Output) {
|
) -> (Expr2, self::Output) {
|
||||||
use roc_parse::ast::Expr::*;
|
use roc_parse::ast::Expr::*;
|
||||||
match parse_expr {
|
match parse_expr {
|
||||||
Float(string) => {
|
Float(string) => {
|
||||||
|
@ -646,7 +646,7 @@ pub fn to_expr2<'a>(
|
||||||
|
|
||||||
let captured_symbols = PoolVec::new(captured_symbols.into_iter(), env.pool);
|
let captured_symbols = PoolVec::new(captured_symbols.into_iter(), env.pool);
|
||||||
|
|
||||||
let extra = crate::ast::ClosureExtra {
|
let extra = ClosureExtra {
|
||||||
return_type: env.var_store.fresh(), // 4B
|
return_type: env.var_store.fresh(), // 4B
|
||||||
captured_symbols, // 8B
|
captured_symbols, // 8B
|
||||||
closure_type: env.var_store.fresh(), // 4B
|
closure_type: env.var_store.fresh(), // 4B
|
||||||
|
@ -1091,7 +1091,7 @@ fn canonicalize_when_branch<'a>(
|
||||||
scope: &mut Scope,
|
scope: &mut Scope,
|
||||||
branch: &'a roc_parse::ast::WhenBranch<'a>,
|
branch: &'a roc_parse::ast::WhenBranch<'a>,
|
||||||
output: &mut Output,
|
output: &mut Output,
|
||||||
) -> (crate::ast::WhenBranch, References) {
|
) -> (WhenBranch, References) {
|
||||||
let patterns = PoolVec::with_capacity(branch.patterns.len() as u32, env.pool);
|
let patterns = PoolVec::with_capacity(branch.patterns.len() as u32, env.pool);
|
||||||
|
|
||||||
let original_scope = scope;
|
let original_scope = scope;
|
||||||
|
@ -1149,7 +1149,7 @@ fn canonicalize_when_branch<'a>(
|
||||||
output.union(branch_output);
|
output.union(branch_output);
|
||||||
|
|
||||||
(
|
(
|
||||||
crate::ast::WhenBranch {
|
WhenBranch {
|
||||||
patterns,
|
patterns,
|
||||||
body: value_id,
|
body: value_id,
|
||||||
guard,
|
guard,
|
9
editor/src/lang/mod.rs
Normal file
9
editor/src/lang/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
pub mod ast;
|
||||||
|
mod def;
|
||||||
|
mod expr;
|
||||||
|
pub mod file;
|
||||||
|
mod module;
|
||||||
|
mod pattern;
|
||||||
|
mod pool;
|
||||||
|
mod scope;
|
||||||
|
mod types;
|
|
@ -2,14 +2,14 @@
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
#![allow(unused_variables)]
|
#![allow(unused_variables)]
|
||||||
use crate::ast::{FunctionDef, ValueDef};
|
use crate::lang::ast::{FunctionDef, ValueDef};
|
||||||
use crate::def::{canonicalize_defs, sort_can_defs, Declaration, Def};
|
use crate::lang::def::{canonicalize_defs, sort_can_defs, Declaration, Def};
|
||||||
use crate::expr::Env;
|
use crate::lang::expr::Env;
|
||||||
use crate::expr::Output;
|
use crate::lang::expr::Output;
|
||||||
use crate::pattern::Pattern2;
|
use crate::lang::pattern::Pattern2;
|
||||||
use crate::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::scope::Scope;
|
use crate::lang::scope::Scope;
|
||||||
use crate::types::Alias;
|
use crate::lang::types::Alias;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_can::operator::desugar_def;
|
use roc_can::operator::desugar_def;
|
||||||
use roc_collections::all::{default_hasher, ImMap, ImSet, MutMap, MutSet, SendMap};
|
use roc_collections::all::{default_hasher, ImMap, ImSet, MutMap, MutSet, SendMap};
|
||||||
|
@ -176,7 +176,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
|
|
||||||
match sort_can_defs(&mut env, defs, Output::default()) {
|
match sort_can_defs(&mut env, defs, Output::default()) {
|
||||||
(Ok(mut declarations), output) => {
|
(Ok(mut declarations), output) => {
|
||||||
use crate::def::Declaration::*;
|
use Declaration::*;
|
||||||
|
|
||||||
for decl in declarations.iter() {
|
for decl in declarations.iter() {
|
||||||
match decl {
|
match decl {
|
|
@ -1,10 +1,10 @@
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
use crate::ast::{ExprId, FloatVal, IntVal};
|
use crate::lang::ast::{ExprId, FloatVal, IntVal};
|
||||||
use crate::expr::{to_expr_id, Env, Output};
|
use crate::lang::expr::{to_expr_id, Env, Output};
|
||||||
use crate::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::scope::Scope;
|
use crate::lang::scope::Scope;
|
||||||
use roc_can::expr::unescape_char;
|
use roc_can::expr::unescape_char;
|
||||||
use roc_can::num::{finish_parsing_base, finish_parsing_float, finish_parsing_int};
|
use roc_can::num::{finish_parsing_base, finish_parsing_float, finish_parsing_int};
|
||||||
use roc_module::symbol::Symbol;
|
use roc_module::symbol::Symbol;
|
|
@ -1,8 +1,8 @@
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
use crate::pool::{Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::types::{Alias, TypeId};
|
use crate::lang::types::{Alias, TypeId};
|
||||||
use roc_collections::all::{MutMap, MutSet};
|
use roc_collections::all::{MutMap, MutSet};
|
||||||
use roc_module::ident::{Ident, Lowercase};
|
use roc_module::ident::{Ident, Lowercase};
|
||||||
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
|
@ -1,9 +1,9 @@
|
||||||
#![allow(clippy::all)]
|
#![allow(clippy::all)]
|
||||||
#![allow(dead_code)]
|
#![allow(dead_code)]
|
||||||
#![allow(unused_imports)]
|
#![allow(unused_imports)]
|
||||||
use crate::expr::Env;
|
use crate::lang::expr::Env;
|
||||||
use crate::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
use crate::lang::pool::{NodeId, Pool, PoolStr, PoolVec, ShallowClone};
|
||||||
use crate::scope::Scope;
|
use crate::lang::scope::Scope;
|
||||||
// use roc_can::expr::Output;
|
// use roc_can::expr::Output;
|
||||||
use roc_collections::all::{MutMap, MutSet};
|
use roc_collections::all::{MutMap, MutSet};
|
||||||
use roc_module::ident::{Ident, TagName};
|
use roc_module::ident::{Ident, TagName};
|
|
@ -8,14 +8,15 @@
|
||||||
|
|
||||||
// See this link to learn wgpu: https://sotrh.github.io/learn-wgpu/
|
// See this link to learn wgpu: https://sotrh.github.io/learn-wgpu/
|
||||||
|
|
||||||
use crate::buffer::create_rect_buffers;
|
|
||||||
use crate::error::print_err;
|
use crate::error::print_err;
|
||||||
use crate::ortho::{init_ortho, update_ortho_buffer, OrthoResources};
|
use crate::graphics::lowlevel::buffer::create_rect_buffers;
|
||||||
use crate::rect::Rect;
|
use crate::graphics::lowlevel::ortho::{init_ortho, update_ortho_buffer, OrthoResources};
|
||||||
|
use crate::graphics::lowlevel::vertex::Vertex;
|
||||||
|
use crate::graphics::primitives::rect::Rect;
|
||||||
|
use crate::graphics::primitives::text::{build_glyph_brush, queue_text_draw, Text};
|
||||||
use crate::selection::create_selection_rects;
|
use crate::selection::create_selection_rects;
|
||||||
use crate::tea::{model, update};
|
use crate::tea::{model, update};
|
||||||
use crate::text::{build_glyph_brush, is_newline, Text};
|
use crate::util::is_newline;
|
||||||
use crate::vertex::Vertex;
|
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use model::Position;
|
use model::Position;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
@ -26,27 +27,14 @@ use winit::event;
|
||||||
use winit::event::{Event, ModifiersState};
|
use winit::event::{Event, ModifiersState};
|
||||||
use winit::event_loop::ControlFlow;
|
use winit::event_loop::ControlFlow;
|
||||||
|
|
||||||
pub mod ast;
|
|
||||||
mod buffer;
|
|
||||||
mod colors;
|
|
||||||
mod def;
|
|
||||||
pub mod error;
|
pub mod error;
|
||||||
pub mod expr;
|
pub mod graphics;
|
||||||
pub mod file;
|
|
||||||
mod keyboard_input;
|
mod keyboard_input;
|
||||||
mod module;
|
pub mod lang;
|
||||||
mod ortho;
|
|
||||||
mod pattern;
|
|
||||||
pub mod pool;
|
|
||||||
mod rect;
|
|
||||||
mod scope;
|
|
||||||
mod selection;
|
mod selection;
|
||||||
mod tea;
|
mod tea;
|
||||||
pub mod text;
|
|
||||||
mod types;
|
|
||||||
mod util;
|
mod util;
|
||||||
mod vec_result;
|
mod vec_result;
|
||||||
mod vertex;
|
|
||||||
|
|
||||||
/// The editor is actually launched from the CLI if you pass it zero arguments,
|
/// The editor is actually launched from the CLI if you pass it zero arguments,
|
||||||
/// or if you provide it 1 or more files or directories to open on launch.
|
/// or if you provide it 1 or more files or directories to open on launch.
|
||||||
|
@ -315,8 +303,8 @@ fn make_rect_pipeline(
|
||||||
&pipeline_layout,
|
&pipeline_layout,
|
||||||
swap_chain_descr.format,
|
swap_chain_descr.format,
|
||||||
&[Vertex::DESC],
|
&[Vertex::DESC],
|
||||||
wgpu::include_spirv!("shaders/rect.vert.spv"),
|
wgpu::include_spirv!("graphics/shaders/rect.vert.spv"),
|
||||||
wgpu::include_spirv!("shaders/rect.frag.spv"),
|
wgpu::include_spirv!("graphics/shaders/rect.frag.spv"),
|
||||||
);
|
);
|
||||||
|
|
||||||
(pipeline, ortho)
|
(pipeline, ortho)
|
||||||
|
@ -399,11 +387,11 @@ fn queue_all_text(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
text::queue_text_draw(&main_label, glyph_brush);
|
queue_text_draw(&main_label, glyph_brush);
|
||||||
|
|
||||||
text::queue_text_draw(&caret_pos_label, glyph_brush);
|
queue_text_draw(&caret_pos_label, glyph_brush);
|
||||||
|
|
||||||
text::queue_text_draw(&code_text, glyph_brush)
|
queue_text_draw(&code_text, glyph_brush)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_text_state(ed_model: &mut model::Model, received_char: &char) {
|
fn update_text_state(ed_model: &mut model::Model, received_char: &char) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::colors;
|
|
||||||
use crate::error::{EdResult, InvalidSelection};
|
use crate::error::{EdResult, InvalidSelection};
|
||||||
use crate::rect::Rect;
|
use crate::graphics::colors;
|
||||||
|
use crate::graphics::primitives::rect::Rect;
|
||||||
use crate::tea::model::RawSelection;
|
use crate::tea::model::RawSelection;
|
||||||
use crate::vec_result::get_res;
|
use crate::vec_result::get_res;
|
||||||
use bumpalo::collections::Vec as BumpVec;
|
use bumpalo::collections::Vec as BumpVec;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::tea::model::{Position, RawSelection};
|
use crate::tea::model::{Position, RawSelection};
|
||||||
use crate::text::is_newline;
|
use crate::util::is_newline;
|
||||||
use std::cmp::{max, min};
|
use std::cmp::{max, min};
|
||||||
|
|
||||||
pub fn move_caret_left(
|
pub fn move_caret_left(
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// Taken from https://github.com/sotrh/learn-wgpu
|
pub fn is_newline(char_ref: &char) -> bool {
|
||||||
// by Benjamin Hansen, licensed under the MIT license
|
let newline_codes = vec!['\u{d}'];
|
||||||
pub fn size_of_slice<T: Sized>(slice: &[T]) -> usize {
|
|
||||||
std::mem::size_of::<T>() * slice.len()
|
newline_codes.contains(char_ref)
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ extern crate indoc;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod test_file {
|
mod test_file {
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_editor::file::File;
|
use roc_editor::lang::file::File;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue