Add icon
This commit is contained in:
parent
3a39fab87a
commit
2632289fc8
@ -13,13 +13,15 @@ use sdl2::event::Event;
|
||||
use sdl2::hint;
|
||||
use sdl2::keyboard::{Keycode, Mod};
|
||||
use sdl2::mouse::MouseButton;
|
||||
use sdl2::pixels::Color;
|
||||
use sdl2::pixels::{Color, PixelFormatEnum};
|
||||
use sdl2::surface::Surface;
|
||||
use sdl2::rect::{Point, Rect};
|
||||
use sdl2::render::Canvas;
|
||||
use sdl2::ttf::Sdl2TtfContext;
|
||||
use sdl2::video::Window;
|
||||
use sdl2::EventPump;
|
||||
use sdl2::{Sdl, TimerSubsystem, VideoSubsystem};
|
||||
use sdl2::rwops::RWops;
|
||||
|
||||
pub mod app_state;
|
||||
pub mod caret_manager;
|
||||
@ -61,6 +63,7 @@ impl Application {
|
||||
pub fn new() -> Self {
|
||||
let config = Rc::new(Config::new());
|
||||
let sdl_context = sdl2::init().unwrap();
|
||||
|
||||
hint::set("SDL_GL_MULTISAMPLEBUFFERS", "1");
|
||||
hint::set("SDL_GL_MULTISAMPLESAMPLES", "8");
|
||||
hint::set("SDL_GL_ACCELERATED_VISUAL", "1");
|
||||
@ -69,12 +72,20 @@ impl Application {
|
||||
|
||||
let video_subsystem = sdl_context.video().unwrap();
|
||||
|
||||
let window = video_subsystem
|
||||
let mut window: Window = video_subsystem
|
||||
.window("Rider", config.width(), config.height())
|
||||
.position_centered()
|
||||
.opengl()
|
||||
.build()
|
||||
.unwrap();
|
||||
let icon_bytes = include_bytes!("../../assets/gear-64x64.bmp").clone();
|
||||
let mut rw = RWops::from_bytes(&icon_bytes).unwrap();
|
||||
let mut icon = Surface::load_bmp_rw(&mut rw).unwrap();
|
||||
// let mut icon = Surface::from_data(
|
||||
// &mut icon_bytes,
|
||||
// 64, 64, 64, PixelFormatEnum::RGB24
|
||||
// ).unwrap();
|
||||
window.set_icon(&mut icon);
|
||||
|
||||
let canvas = window.into_canvas().accelerated().build().unwrap();
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl EditorConfig {
|
||||
let mut default_font_path = directories::fonts_dir();
|
||||
default_font_path.push("DejaVuSansMono.ttf");
|
||||
Self {
|
||||
character_size: 16,
|
||||
character_size: 14,
|
||||
font_path: default_font_path.to_str().unwrap().to_string(),
|
||||
current_theme: "railscasts".to_string(),
|
||||
margin_left: 10,
|
||||
|
@ -148,10 +148,11 @@ impl Token {
|
||||
pub fn parse(text: String, language: &Language) -> Vec<TokenType> {
|
||||
match language {
|
||||
&Language::PlainText => plain::lexer::Lexer::new(text.as_str())
|
||||
// .inspect(|tok| println!("tok: {:?}", tok))
|
||||
.inspect(|tok| warn!("tok: {:?}", tok))
|
||||
.map(|t| t.0)
|
||||
.collect(),
|
||||
&Language::Rust => rust_lang::lexer::Lexer::new(text.as_str())
|
||||
.inspect(|tok| warn!("tok: {:?}", tok))
|
||||
.map(|t| t.0)
|
||||
.collect(),
|
||||
}
|
||||
|
@ -7,11 +7,19 @@ pub mod lexer {
|
||||
lexer! {
|
||||
fn next_token(text: 'a) -> (TokenType, &'a str);
|
||||
|
||||
r"[ \t\r\n]" => (TokenType::Whitespace {
|
||||
r"( +|\t+|\n+)" => (TokenType::Whitespace {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
|
||||
r"[+-/*%=]" => (TokenType::Operator {
|
||||
r"(\d+|\d+\.\d+|'[\S]')" => (TokenType::Literal {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
|
||||
r"[+-/*%=<>]" => (TokenType::Operator {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
|
||||
r"(:|::|\{|\}|\[|\]|,)" => (TokenType::Separator {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
|
||||
@ -19,7 +27,7 @@ pub mod lexer {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
|
||||
r"[^ \t\r\n]+" => (TokenType::Identifier {
|
||||
r"[^ \t\r\n:+-/*,]+" => (TokenType::Identifier {
|
||||
token: Token::new(text.to_string(), 0, 0, 0, 0)
|
||||
}, text),
|
||||
}
|
||||
|
@ -46,10 +46,7 @@ fn init_logger() {
|
||||
fn main() {
|
||||
let mut app = Application::new();
|
||||
app.init();
|
||||
|
||||
init_logger();
|
||||
|
||||
// app.open_file("./assets/examples/example.txt".to_string());
|
||||
app.open_file("./assets/examples/test.rs".to_string());
|
||||
app.run();
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ fn railscasts_theme() -> Theme {
|
||||
},
|
||||
operator: ThemeConfig {
|
||||
color: SerdeColor {
|
||||
r: 0,
|
||||
r: 200,
|
||||
g: 0,
|
||||
b: 0,
|
||||
a: 0,
|
||||
@ -142,9 +142,9 @@ fn railscasts_theme() -> Theme {
|
||||
},
|
||||
separator: ThemeConfig {
|
||||
color: SerdeColor {
|
||||
r: 121,
|
||||
g: 121,
|
||||
b: 121,
|
||||
r: 221,
|
||||
g: 221,
|
||||
b: 221,
|
||||
a: 0,
|
||||
},
|
||||
italic: false,
|
||||
|
@ -45,12 +45,6 @@ impl EditorFileToken {
|
||||
pub fn get_line(&self, line: &usize) -> Option<Vec<&TextCharacter>> {
|
||||
let mut vec: Vec<&TextCharacter> = vec![];
|
||||
for c in self.characters.iter() {
|
||||
let _tmp = (
|
||||
line.clone(),
|
||||
c.line().clone(),
|
||||
self.token_type.is_new_line(),
|
||||
c.text_character(),
|
||||
);
|
||||
match (
|
||||
line.clone(),
|
||||
c.line().clone(),
|
||||
@ -94,7 +88,7 @@ impl EditorFileToken {
|
||||
c.clone(),
|
||||
self.token_type.start() + index,
|
||||
self.token_type.line(),
|
||||
color.clone(),
|
||||
color,
|
||||
self.config.clone(),
|
||||
);
|
||||
text_character.update_view(renderer);
|
||||
|
Loading…
Reference in New Issue
Block a user