removed DPI

This commit is contained in:
Allen Webster 2016-04-21 20:50:16 -04:00
parent b3c4f2b6e8
commit f5c3aa2da4
11 changed files with 935 additions and 2491 deletions

View File

@ -3385,7 +3385,7 @@ App_Init_Sig(app_init){
font_setup[i].file_name_len);
String name = make_string(font_setup[i].c_name,
font_setup[i].name_len);
i32 pt_size = DpiMultiplier(font_setup[i].pt_size, target->dpi);
i32 pt_size = font_setup[i].pt_size;
font_set_add(partition, models->font_set, file_name, name, pt_size);
}

View File

@ -3536,19 +3536,17 @@ file_step(View *view, i32_Rect region, Input_Summary *user_input, b32 is_active)
}
internal void
view_do_queries(View *view, GUI_Target *target){
do_widget(View *view, GUI_Target *target){
Query_Slot *slot;
Query_Bar *bar;
gui_begin_serial_section(target);
for (slot = view->query_set.used_slot; slot != 0; slot = slot->next){
bar = slot->query_bar;
gui_do_text_field(target, bar->prompt, bar->string);
}
}
internal void
do_widget(View *view, GUI_Target *target){
gui_begin_serial_section(target);
view_do_queries(view, target);
gui_end_serial_section(target);
}
@ -3624,10 +3622,33 @@ step_file_view(System_Functions *system, View *view, b32 is_active){
f32 min_target_y = view->file_scroll.min_y;
f32 max_target_y = view->file_scroll.max_y;
b32 debug = 1;
gui_begin_top_level(target);
{
gui_do_top_bar(target);
if (debug){
char prompt_space[256];
char text_space[256];
String prompt, text;
prompt = make_fixed_width_string(prompt_space);
text = make_fixed_width_string(text_space);
copy(&prompt, "U: ");
int_to_str((int)view->gui_scroll.target_y, &text);
gui_do_text_field(target, prompt, text);
copy(&prompt, "O: ");
int_to_str((int)view->gui_target.scroll_original.target_y, &text);
gui_do_text_field(target, prompt, text);
copy(&prompt, "N: ");
int_to_str((int)view->gui_target.scroll_updated.target_y, &text);
gui_do_text_field(target, prompt, text);
}
if (view->showing_ui == VUI_None){
gui_begin_overlap(target);
do_widget(view, target);

View File

@ -188,7 +188,7 @@ struct Render_Target{
Draw_Pop_Clip *pop_clip;
Draw_Push_Piece *push_piece;
i32 dpi;
//i32 dpi;
};
#define DpiMultiplier(n,dpi) ((n) * (dpi) / 96)

View File

@ -104,7 +104,7 @@
; [] simple multi-line editing
; [] allow for arbitrary wrap positions independent of view width
; [] word level wrapping ~ temporary measure really want to have totally formatted code
; [] manipulate scroll starget API
; [] manipulate scroll target API
; [] error parsing and jump to error
; [] additional hooks
; [X] new file
@ -112,6 +112,13 @@
; [] double binding warnings
; [] kill rect
;
; GUI related tech
; [X] consolidate all GUI code properly
; [X] rewrite GUI
; [] arrow navigation of GUIs
; [] GUI API
; [] text links -> arbitrary commands / callbacks?
;
; search related tech
; [X] replace word (incremental and/or in range)
; [] optimize search
@ -119,13 +126,6 @@
; [] improved custom API for text "streams"
; [] caps insensitivety
;
; GUI related tech
; [X] consolidate all GUI code properly
; [] rewrite GUI
; [] GUI API
; [] arrow navigation of GUIs
; [] text links -> arbitrary commands / callbacks?
;
; theme related business
; [] fix the versioning system for themes
; [] theme switch per panel?

View File

@ -1,5 +1,5 @@
@echo off
"w:\4ed\misc\build_exp.bat" /Zi
REM "w:\4ed\misc\build_all.bat" /DFRED_SUPER /DFRED_NOT_PACKAGE /Zi
REM "w:\4ed\misc\build_exp.bat" /Zi
"w:\4ed\misc\build_all.bat" /DFRED_SUPER /DFRED_NOT_PACKAGE /Zi
REM "w:\4ed\misc\build_all.bat" /O2 /Zi

View File

@ -99,6 +99,7 @@ struct Lex_FSM{
union{
unsigned char int_state;
unsigned char directive_state;
unsigned char sub_machine;
};
unsigned char emit_token;
unsigned char multi_line;

File diff suppressed because it is too large Load Diff

View File

@ -317,6 +317,9 @@ struct Lex_Data{
unsigned char pp_state;
unsigned char completed;
unsigned short *key_eq_classes;
unsigned char *key_table;
Cpp_Token token;
int __pc__;
@ -354,6 +357,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, char *chunk, int size, Cpp_Token_Stack *token_
DrCase(4);
DrCase(5);
DrCase(6);
DrCase(7);
}
for (;;){
@ -481,6 +485,37 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, char *chunk, int size, Cpp_Token_Stack *token_
case LS_identifier:
{
S.fsm.state = 0;
S.fsm.emit_token = 0;
S.fsm.sub_machine = 0;
S.key_table = key_tables[S.fsm.sub_machine];
S.key_eq_classes = key_eq_class_tables[S.fsm.sub_machine];
--S.pos;
for (;;){
for (; S.fsm.state < LSKEY_totally_finished && S.pos < end_pos;){
for (; S.fsm.state < LSKEY_table_transition && S.pos < end_pos;){
c = chunk[S.pos++];
S.fsm.state = S.key_table[S.fsm.state + S.key_eq_classes[c]];
}
// TODO(allen): udpate table
S.fsm.sub_machine = 0;
S.key_table = key_tables[S.fsm.sub_machine];
S.key_eq_classes = key_eq_class_tables[S.fsm.sub_machine];
}
S.fsm.emit_token = (S.fsm.int_state >= LSKEY_totally_finished);
if (S.fsm.emit_token == 0){
DrYield(7, 1);
}
else break;
}
--S.pos;
// TODO(allen): do stuff regarding the actual type of the token
S.token.type = CPP_TOKEN_INTEGER_CONSTANT;
S.token.flags = 0;
#if 0
--S.pos;
int word_size = S.pos - S.token_start;
@ -513,6 +548,8 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, char *chunk, int size, Cpp_Token_Stack *token_
S.token.flags = 0;
}
}
#endif
}break;
case LS_pound:
@ -558,7 +595,6 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, char *chunk, int size, Cpp_Token_Stack *token_
case LS_number:
case LS_number0:
case LS_hex:
{
S.fsm.int_state = LSINT_default;
S.fsm.emit_token = 0;
--S.pos;
@ -575,7 +611,6 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, char *chunk, int size, Cpp_Token_Stack *token_
else break;
}
--S.pos;
}
S.token.type = CPP_TOKEN_INTEGER_CONSTANT;
S.token.flags = 0;

View File

@ -337,10 +337,10 @@ show_time(Times t, int repeats, char *type){
#define BASE_DIR "w:/4ed/data/test/"
int main(){
int repeats = 100;
int verbose_level = -1;
int chunk_start = 0;
int chunk_end = 0;
int repeats = 1;
int verbose_level = 0;
int chunk_start = 1;
int chunk_end = 32;
#define TEST_FILE "junk.cpp"
#define SINGLE_ITEM 0

View File

@ -12,17 +12,8 @@
Next Time:
Finish linking from one FSM to the next in the keyword recognizer.
1. Reduce away states that only ever show up as terminal states.
2. Reduce away states that cannot ever be reached.
3. Output new enum that only includes the reduced states.
4. How to name these things so that we can deal with different
pp_states that want very similar fsm main states?
4.a. Perhaps a lookup table to convert back to canonical enum
values after the fsm is finished?
5. How can we eliminate S.tb for keywords?? They are too long for
building into an FSM table... (state,index,input) -> state ???
1. Make sure each FSM follows the rules about state types correctly.
2. Make a look up table from final states to resulting token types.
*/
@ -176,6 +167,9 @@ struct FSM{
struct FSM_Stack{
FSM *fsms;
int count, max;
unsigned char table_transition_state;
unsigned char final_state;
};
struct Match_Node{
@ -212,7 +206,8 @@ FSM*
get_fsm(FSM_Stack *stack){
FSM* result = 0;
assert(stack->count < stack->max);
result = &stack->fsms[stack->count++];
result = &stack->fsms[stack->count];
++stack->count;
return(result);
}
@ -225,7 +220,7 @@ get_tree(Match_Tree_Stack *stack){
}
FSM
fsm_init(unsigned short max){
fsm_init(unsigned short max, unsigned char terminal_base){
FSM fsm;
int memsize;
fsm.max = max;
@ -239,6 +234,7 @@ fsm_init(unsigned short max){
fsm.term_states = (FSM_State*)malloc(memsize);
fsm.comment = 0;
fsm.terminal_base = terminal_base;
return(fsm);
}
@ -328,9 +324,10 @@ match_add_word(Match_Node *node, int word){
}
FSM_State*
fsm_get_state(FSM *fsm, unsigned char terminal_base){
fsm_get_state(FSM *fsm){
FSM_State *result;
unsigned short i;
unsigned char terminal_base = fsm->terminal_base;
assert(fsm->count < fsm->max);
result = &fsm->states[fsm->count++];
for (i = 0; i < 256; ++i){
@ -371,12 +368,13 @@ struct Terminal_Lookup_Table{
};
void
process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm, unsigned char terminal_base,
process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, FSM *fsm,
Terminal_Lookup_Table *terminal_table = 0, int levels_to_go = -1, Future_FSM_Stack *unfinished_fsms = 0){
int next_index = node->index + 1;
int match_count = node->count;
FSM_State *this_state = node->state;
unsigned char terminal_base = fsm->terminal_base;
int i, j, *words = node->words;
@ -416,7 +414,7 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F
next_nodes[c]->state = fsm_get_term_state(fsm, state_override++);
}
else{
next_nodes[c]->state = fsm_get_state(fsm, terminal_base);
next_nodes[c]->state = fsm_get_state(fsm);
}
if (newest_child == 0){
@ -463,7 +461,7 @@ process_match_node(String_And_Flag *input, Match_Node *node, Match_Tree *tree, F
}
else{
for (n = node->first_child; n; n = n->next_sibling){
process_match_node(input, n, tree, fsm, terminal_base, terminal_table, levels_to_go - 1, unfinished_fsms);
process_match_node(input, n, tree, fsm, terminal_table, levels_to_go - 1, unfinished_fsms);
}
}
}
@ -476,10 +474,10 @@ generate_pp_directive_fsm(){
FSM_State *root_state;
int i;
fsm = fsm_init(200);
fsm = fsm_init(200, 200);
tree = tree_init(200);
root_state = fsm_get_state(&fsm, 200);
root_state = fsm_get_state(&fsm);
root_node = match_get_node(&tree);
match_init_node(root_node, ArrayCount(preprop_strings));
@ -489,7 +487,7 @@ generate_pp_directive_fsm(){
root_node->count = ArrayCount(preprop_strings);
root_node->state = root_state;
root_node->index = -1;
process_match_node(preprop_strings, root_node, &tree, &fsm, 200);
process_match_node(preprop_strings, root_node, &tree, &fsm);
root_state->transition_rule[' '] = 0;
root_state->transition_rule['\t'] = 0;
@ -530,6 +528,7 @@ generate_keyword_fsms(){
fsm_stack.max = 1024;
fsm_stack.count = 0;
fsm_stack.fsms = (FSM*)malloc(sizeof(FSM)*fsm_stack.max);
fsm_stack.table_transition_state = 26;
tree_stack.max = 1024;
tree_stack.count = 0;
@ -542,10 +541,10 @@ generate_keyword_fsms(){
fsm = get_fsm(&fsm_stack);
tree = get_tree(&tree_stack);
*fsm = fsm_init(200);
*fsm = fsm_init(200, fsm_stack.table_transition_state);
*tree = tree_init(200);
root_state = fsm_get_state(fsm, 40);
root_state = fsm_get_state(fsm);
root_node = match_get_node(tree);
match_init_node(root_node, ArrayCount(keyword_strings));
for (i = 0; i < ArrayCount(keyword_strings); ++i){
@ -556,7 +555,7 @@ generate_keyword_fsms(){
root_node->state = root_state;
root_node->index = -1;
process_match_node(keyword_strings, root_node, tree, fsm, 40, &terminal_table, 2, &unfinished_futures);
process_match_node(keyword_strings, root_node, tree, fsm, &terminal_table, 2, &unfinished_futures);
while (unfinished_futures.count > 0){
future = pop_future_fsm(&unfinished_futures);
@ -564,10 +563,10 @@ generate_keyword_fsms(){
fsm = get_fsm(&fsm_stack);
tree = get_tree(&tree_stack);
*fsm = fsm_init(200);
*fsm = fsm_init(200, fsm_stack.table_transition_state);
*tree = tree_init(200);
root_state = fsm_get_state(fsm, 40);
root_state = fsm_get_state(fsm);
root_node = match_get_node(tree);
match_copy_init_node(root_node, future->source);
root_node->state = root_state;
@ -577,9 +576,13 @@ generate_keyword_fsms(){
sprintf(space, "%s\n", keyword_strings[root_node->words[i]].str);
fsm_add_comment(fsm, space);
}
process_match_node(keyword_strings, root_node, tree, fsm, 40, &terminal_table, 2, &unfinished_futures);
process_match_node(keyword_strings, root_node, tree, fsm, &terminal_table, 12, &unfinished_futures);
}
assert(fsm_stack.count < 255);
fsm_stack.final_state = fsm_stack.table_transition_state + (unsigned char)fsm_stack.count;
return(fsm_stack);
}
@ -697,6 +700,7 @@ main_fsm(Lex_FSM fsm, unsigned char pp_state, unsigned char c){
case LS_default:
if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_'){
fsm.state = LS_identifier;
fsm.emit_token = 1;
}
else if (c >= '1' && c <= '9'){
fsm.state = LS_number;
@ -764,11 +768,13 @@ main_fsm(Lex_FSM fsm, unsigned char pp_state, unsigned char c){
}
break;
#if 0
case LS_identifier:
if (!((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || c == '_')){
fsm.emit_token = 1;
}
break;
#endif
case LS_pound:
switch (c){
@ -1317,6 +1323,7 @@ main(){
FSM_Stack keyword_fsms = generate_keyword_fsms();
char name[1024];
render_variable(file, "unsigned char", "keywords_part_terminal_base", keyword_fsms.fsms[0].terminal_base);
for (int i = 0; i < keyword_fsms.count; ++i){
FSM_Tables partial_keywords_table = generate_table_from_abstract_fsm(keyword_fsms.fsms[i]);
@ -1324,11 +1331,29 @@ main(){
render_comment(file, keyword_fsms.fsms[i].comment);
}
char name[1024];
sprintf(name, "keyword_part_%d_table", i);
render_fsm_table(file, partial_keywords_table, name);
}
begin_ptr_table(file, "short", "key_eq_class_tables");
for (int i = 0; i < keyword_fsms.count; ++i){
sprintf(name, "keyword_part_%d_table_eq_classes", i);
do_table_item_direct(file, name, "");
end_row(file);
}
end_table(file);
begin_ptr_table(file, "char", "key_tables");
for (int i = 0; i < keyword_fsms.count; ++i){
sprintf(name, "keyword_part_%d_table_table", i);
do_table_item_direct(file, name, "");
end_row(file);
}
end_table(file);
fprintf(file, "#define LSKEY_table_transition %d\n", (int)(keyword_fsms.table_transition_state));
fprintf(file, "#define LSKEY_totally_finished %d\n", (int)(keyword_fsms.final_state));
fclose(file);
return(0);
}

View File

@ -1923,14 +1923,6 @@ WinMain(HINSTANCE hInstance,
HDC hdc = GetDC(window_handle);
win32vars.window_hdc = hdc;
i32 xdpi = GetDeviceCaps(hdc, LOGPIXELSX);
i32 ydpi = GetDeviceCaps(hdc, LOGPIXELSY);
win32vars.target.dpi = xdpi;
if (win32vars.target.dpi < ydpi){
win32vars.target.dpi = ydpi;
}
GetClientRect(window_handle, &window_rect);
static PIXELFORMATDESCRIPTOR pfd = {