Add font command mapping

pull/1/head
trivernis 4 years ago
parent 809d30a6c8
commit 8a5b6ed2a9

@ -1,9 +1,12 @@
use crate::tokens::constants::TokenPattern; use crate::tokens::constants::TokenPattern;
use crate::tokens::mappings::{ use crate::tokens::mappings::{
get_accent_mappings, get_arrow_mapping, get_greek_mappings, get_grouping_mappings, get_accent_mappings, get_arrow_mapping, get_font_mappings, get_greek_mappings,
get_logical_mappings, get_misc_mappings, get_operation_mappings, get_relation_mapping, get_grouping_mappings, get_logical_mappings, get_misc_mappings, get_operation_mappings,
get_relation_mapping,
};
use crate::tokens::{
Accent, Arrow, FontCommand, Greek, Grouping, Logical, Misc, Operation, Relation, Token,
}; };
use crate::tokens::{Accent, Arrow, Greek, Grouping, Logical, Misc, Operation, Relation, Token};
use charred::tapemachine::CharTapeMachine; use charred::tapemachine::CharTapeMachine;
use std::collections::HashMap; use std::collections::HashMap;
use std::fmt::Debug; use std::fmt::Debug;
@ -136,4 +139,18 @@ impl Tokenizer {
} }
None None
} }
fn parse_font_command(&mut self) -> Option<FontCommand> {
lazy_static! {
static ref FONTC_MAPPING: Vec<HashMap<&'static str, FontCommand>> = get_font_mappings();
}
for mapping in FONTC_MAPPING.iter() {
for key in mapping.keys() {
if self.ctm.check_str_sequence(*key) {
return Some(mapping[key].clone());
}
}
}
None
}
} }

@ -1,5 +1,6 @@
use crate::tokens::constants::accents::*; use crate::tokens::constants::accents::*;
use crate::tokens::constants::arrows::*; use crate::tokens::constants::arrows::*;
use crate::tokens::constants::font_commands::*;
use crate::tokens::constants::greek::*; use crate::tokens::constants::greek::*;
use crate::tokens::constants::grouping::*; use crate::tokens::constants::grouping::*;
use crate::tokens::constants::logical::*; use crate::tokens::constants::logical::*;
@ -8,7 +9,9 @@ use crate::tokens::constants::operations::*;
use crate::tokens::constants::relations::*; use crate::tokens::constants::relations::*;
use crate::tokens::constants::TokenPattern; use crate::tokens::constants::TokenPattern;
use crate::tokens::{Accent, Arrow, Greek, Grouping, Logical, Misc, Operation, Relation}; use crate::tokens::{
Accent, Arrow, FontCommand, Greek, Grouping, Logical, Misc, Operation, Relation,
};
use std::cell::RefCell; use std::cell::RefCell;
use std::collections::HashMap; use std::collections::HashMap;
@ -251,3 +254,18 @@ pub fn get_greek_mappings() -> Vec<HashMap<TokenPattern, Greek>> {
G_BIGOMEGA => Greek::BigOmega, G_BIGOMEGA => Greek::BigOmega,
}] }]
} }
pub fn get_font_mappings() -> Vec<HashMap<&'static str, FontCommand>> {
vec![
hashmap! {
F_BBB => FontCommand::BigOutline
},
hashmap! {
F_BB => FontCommand::Big,
F_CC => FontCommand::Cursive,
F_TT => FontCommand::TText,
F_FR => FontCommand::Fr,
F_SF => FontCommand::SansSerif,
},
]
}

Loading…
Cancel
Save