new gui stuff 10

This commit is contained in:
Allen Webster 2016-03-26 04:06:41 -04:00
parent 216c597df3
commit 022f7176bf
13 changed files with 7272 additions and 7295 deletions

View File

@ -28,9 +28,7 @@ basic_seek(Application_Links *app, Command_ID seek_type, unsigned int flags){
}
#define SEEK_COMMAND(n, dir, flags)\
CUSTOM_COMMAND_SIG(seek_##n##_##dir){\
basic_seek(app, cmdid_seek_##dir, flags);\
}
CUSTOM_COMMAND_SIG(seek_##n##_##dir){ basic_seek(app, cmdid_seek_##dir, flags); }
SEEK_COMMAND(whitespace, right, BoundryWhitespace)
SEEK_COMMAND(whitespace, left, BoundryWhitespace)
@ -59,7 +57,6 @@ long_braces(Application_Links *app, char *text, int size){
push_parameter(app, par_range_start, pos);
push_parameter(app, par_range_end, pos + size);
push_parameter(app, par_clear_blank_lines, 0);
push_parameter(app, par_use_tabs, 1);
exec_command(app, cmdid_auto_tab_range);
}

View File

@ -308,7 +308,7 @@ query_user_general(Application_Links *app, Query_Bar *bar, int force_number){
}
}
}
// NOTE(allen|a3.4.4): All we have to do to update the query bar is edit our
// local Query_Bar struct! This is handy because it means our Query_Bar
// is always correct for typical use without extra work updating the bar.
@ -317,7 +317,9 @@ query_user_general(Application_Links *app, Query_Bar *bar, int force_number){
break;
}
else if (in.key.keycode == key_back){
--bar->string.size;
if (bar->string.size > 0){
--bar->string.size;
}
}
else if (good_character){
append(&bar->string, in.key.character);

35
4ed.cpp
View File

@ -748,6 +748,7 @@ COMMAND_DECL(delete_range){
range = make_range(view->cursor.pos, view->mark);
if (range.start < range.end){
next_cursor_pos = range.start;
Assert(range.end <= buffer_size(&file->state.buffer));
view_replace_range(system, models, view, range.start, range.end, 0, 0, next_cursor_pos);
view_cursor_move(view, next_cursor_pos);
view->mark = range.start;
@ -2881,9 +2882,9 @@ app_hardcode_styles(Models *models){
style_set_name(style, make_lit_string("stb"));
style->main.back_color = 0xFFD6D6D6;
style->main.margin_color = 0xFF9E9E9E;
style->main.margin_color = 0xFF5C5C5C;
style->main.margin_hover_color = 0xFF7E7E7E;
style->main.margin_active_color = 0xFF5C5C5C;
style->main.margin_active_color = 0xFF9E9E9E;
style->main.cursor_color = 0xFF000000;
style->main.at_cursor_color = 0xFFD6D6D6;
style->main.mark_color = 0xFF525252;
@ -3923,7 +3924,7 @@ App_Step_Sig(app_step){
// TOOD(allen): Deduplicate
// TODO(allen): Allow a view to clean up however it wants after a command finishes,
// or after transfering to another view mid command.
// or after transfering to another view mid command?
if (view != 0 && models->command_coroutine == 0){
init_query_set(&view->query_set);
}
@ -3934,7 +3935,7 @@ App_Step_Sig(app_step){
update_command_data(vars, cmd);
ProfileEnd(command_coroutine);
ProfileStart(frame_hook);
if (models->hooks[hook_frame]){
if ((models->hooks[hook_frame])(&app_links)){
@ -3942,6 +3943,23 @@ App_Step_Sig(app_step){
}
}
ProfileStart(frame_hook);
ProfileStart(fill_gui_command_buffers);
{
Panel *panel, *used_panels;
View *view;
b32 active;
used_panels = &models->layout.used_sentinel;
for (dll_items(panel, used_panels)){
view = panel->view;
active = (panel == cmd->panel);
if (step_file_view(view, active)){
app_result.redraw = 1;
}
}
}
ProfileStart(fill_gui_command_buffers);
// NOTE(allen): pass raw input to the panels
ProfileStart(step);
@ -3998,7 +4016,7 @@ App_Step_Sig(app_step){
if (panel == mouse_panel && !mouse->out_of_window){
input.mouse = mouse_state;
}
if (step_file_view(system, exchange, view, panel->inner, active, &input)){
if (do_input_file_view(system, exchange, view, panel->inner, active, &input)){
app_result.redraw = 1;
}
}
@ -4431,7 +4449,6 @@ App_Step_Sig(app_step){
{
if (!file && string.str){
file = working_set_lookup_file(working_set, string);
if (!file){
file = working_set_contains(system, working_set, string);
}
@ -4450,7 +4467,6 @@ App_Step_Sig(app_step){
{
if (!file && string.str){
file = working_set_lookup_file(working_set, string);
if (!file){
file = working_set_contains(system, working_set, string);
}
@ -4475,7 +4491,6 @@ App_Step_Sig(app_step){
if (!file && string.str){
file = working_set_lookup_file(working_set, string);
if (!file){
file = working_set_contains(system, working_set, string);
}
@ -4485,7 +4500,9 @@ App_Step_Sig(app_step){
if (buffer_needs_save(file)){
view_show_interactive(system, view, &models->map_ui,
IAct_Sure_To_Kill, IInt_Sure_To_Kill, make_lit_string("Are you sure?"));
#if 0
copy(&view->dest, file->name.live_name);
#endif
}
else{
working_set_remove(system, working_set, file->name.source_path);
@ -4576,7 +4593,7 @@ App_Step_Sig(app_step){
draw_rectangle(target, full, back_color);
draw_push_clip(target, panel->inner);
draw_file_view(system, exchange, view, cmd->view, panel->inner, active, target, &dead_input);
do_render_file_view(system, exchange, view, cmd->view, panel->inner, active, target, &dead_input);
draw_pop_clip(target);
u32 margin_color;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

2166
4ed_gui_old.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -162,30 +162,31 @@ buffer_backify_next(Buffer_Backify_Loop *loop){
internal_4tech int
buffer_replace_range(Buffer *buffer, int start, int end, char *str, int len, int *shift_amount,
void *scratch, int scratch_size, int *request_amount){
void *scratch, int scratch_size, int *request_amount){
char *data;
int result;
int size;
size = buffer_size(buffer);
assert_4tech(0 <= start);
assert_4tech(start <= end);
assert_4tech(end <= size);
*shift_amount = (len - (end - start));
if (*shift_amount + size <= buffer->max){
data = (char*)buffer->data;
memmove_4tech(data + end + *shift_amount, data + end, buffer->size - end);
buffer->size += *shift_amount;
if (len != 0) memcpy_4tech(data + start, str, len);
result = 0;
}
else{
*request_amount = round_up_4tech(2*(*shift_amount + size), 4 << 10);
result = 1;
}
return(result);
}
@ -199,16 +200,17 @@ buffer_batch_edit_step(Buffer_Batch_State *state, Buffer *buffer, Buffer_Edit *s
result = 0;
shift_total = state->shift_total;
i = state->i;
edit = sorted_edits + i;
for (; i < edit_count; ++i, ++edit){
assert(edit->end + shift_total < buffer_size(buffer));
result = buffer_replace_range(buffer, edit->start + shift_total, edit->end + shift_total,
strings + edit->str_start, edit->len, &shift_amount,
scratch, scratch_size, request_amount);
strings + edit->str_start, edit->len, &shift_amount,
scratch, scratch_size, request_amount);
if (result) break;
shift_total += shift_amount;
}
state->shift_total = shift_total;
state->i = i;

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

@ -58,7 +58,9 @@ enum Lex_Int_State{
LSINT_ul,
LSINT_uL,
LSINT_ll,
LSINT_extra
LSINT_extra,
//
LSINT_count
};
enum Lex_INC_State{

View File

@ -10,6 +10,19 @@ unsigned char whitespace_fsm_table[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0,
};
unsigned short int_fsm_eq_classes[] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,24, 0, 0, 0, 0, 0, 0, 0, 0,16, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};
const int num_int_fsm_eq_classes = 4;
unsigned char int_fsm_table[] = {
8, 9,10,11,12,13,14,15,
3, 5,10, 6,12, 7,14,15,
1, 9, 7, 7,12,13, 7,15,
2, 4, 6,11, 7,13,14,15,
};
unsigned char multiline_state_table[] = {
0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
};

File diff suppressed because it is too large Load Diff

View File

@ -17,7 +17,10 @@
#include "../4cpp_lexer_types.h"
#define FCPP_LEXER_IMPLEMENTATION
#include "../4cpp_lexer.h"
#include "4cpp_new_lexer.h"
namespace new_lex{
# include "4cpp_new_lexer.h"
}
#include <windows.h>
#include <intrin.h>

View File

@ -528,6 +528,40 @@ struct FSM_Tables{
unsigned short state_count;
};
void
do_table_reduction(FSM_Tables *table, unsigned short state_count){
{
table->eq_class_counter = 0;
unsigned char *c_line = table->full_transition_table;
for (unsigned short c = 0; c < 256; ++c){
if (table->marks[c] == 0){
table->eq_class[c] = table->eq_class_counter;
table->eq_class_rep[table->eq_class_counter] = (unsigned char)c;
unsigned char *c2_line = c_line + state_count;
for (unsigned short c2 = c + 1; c2 < 256; ++c2){
if (memcmp(c_line, c2_line, state_count) == 0){
table->marks[c2] = 1;
table->eq_class[c2] = table->eq_class_counter;
}
c2_line += state_count;
}
++table->eq_class_counter;
}
c_line += state_count;
}
}
table->reduced_transition_table = (unsigned char*)malloc(state_count * table->eq_class_counter);
{
unsigned char *r_line = table->reduced_transition_table;
for (unsigned short eq = 0; eq < table->eq_class_counter; ++eq){
unsigned char *u_line = table->full_transition_table + state_count * table->eq_class_rep[eq];
memcpy(r_line, u_line, state_count);
r_line += state_count;
}
}
}
FSM_Tables
generate_whitespace_skip_table(){
unsigned char state_count = LSPP_count;
@ -551,36 +585,36 @@ generate_whitespace_skip_table(){
}
}
table.eq_class_counter = 0;
unsigned char *c_line = table.full_transition_table;
for (unsigned short c = 0; c < 256; ++c){
if (table.marks[c] == 0){
table.eq_class[c] = table.eq_class_counter;
table.eq_class_rep[table.eq_class_counter] = (unsigned char)c;
unsigned char *c2_line = c_line + state_count;
for (unsigned short c2 = c + 1; c2 < 256; ++c2){
if (memcmp(c_line, c2_line, state_count) == 0){
table.marks[c2] = 1;
table.eq_class[c2] = table.eq_class_counter;
}
c2_line += state_count;
}
++table.eq_class_counter;
}
c_line += state_count;
}
do_table_reduction(&table, state_count);
table.reduced_transition_table = (unsigned char*)malloc(state_count * table.eq_class_counter);
i = 0;
for (unsigned short eq = 0; eq < table.eq_class_counter; ++eq){
return(table);
}
FSM_Tables
generate_int_table(){
unsigned char state_count = LSINT_count;
FSM_Tables table;
table.full_transition_table = (unsigned char*)malloc(state_count * 256);
table.marks = (unsigned char*)malloc(state_count * 256);
table.eq_class = (unsigned char*)malloc(state_count * 256);
table.eq_class_rep = (unsigned char*)malloc(state_count * 256);
table.state_count = state_count;
memset(table.marks, 0, 256);
int i = 0;
Lex_FSM fsm = {0};
Lex_FSM new_fsm;
for (unsigned short c = 0; c < 256; ++c){
for (unsigned char state = 0; state < state_count; ++state){
wfsm.pp_state = state;
wfsm.white_done = 0;
new_wfsm = whitespace_skip_fsm(wfsm, table.eq_class_rep[eq]);
table.reduced_transition_table[i++] = new_wfsm.pp_state + state_count*new_wfsm.white_done;
fsm.int_state = state;
fsm.emit_token = 0;
new_fsm = int_fsm(fsm, (unsigned char)c);
table.full_transition_table[i++] = new_fsm.int_state + state_count*new_fsm.emit_token;
}
}
do_table_reduction(&table, state_count);
return(table);
}
@ -607,35 +641,7 @@ generate_fsm_table(unsigned char pp_state){
}
}
table.eq_class_counter = 0;
unsigned char *c_line = table.full_transition_table;
for (unsigned short c = 0; c < 256; ++c){
if (table.marks[c] == 0){
table.eq_class[c] = table.eq_class_counter;
table.eq_class_rep[table.eq_class_counter] = (unsigned char)c;
unsigned char *c2_line = c_line + state_count;
for (unsigned short c2 = c + 1; c2 < 256; ++c2){
if (memcmp(c_line, c2_line, state_count) == 0){
table.marks[c2] = 1;
table.eq_class[c2] = table.eq_class_counter;
}
c2_line += state_count;
}
++table.eq_class_counter;
}
c_line += state_count;
}
table.reduced_transition_table = (unsigned char*)malloc(state_count * table.eq_class_counter);
i = 0;
for (unsigned short eq = 0; eq < table.eq_class_counter; ++eq){
for (unsigned char state = 0; state < state_count; ++state){
fsm.state = state;
fsm.emit_token = 0;
new_fsm = main_fsm(fsm, pp_state, table.eq_class_rep[eq]);
table.reduced_transition_table[i++] = new_fsm.state + state_count*new_fsm.emit_token;
}
}
do_table_reduction(&table, state_count);
return(table);
}
@ -686,13 +692,16 @@ int main(){
FSM_Tables wtables = generate_whitespace_skip_table();
render_fsm_table(file, wtables, "whitespace_fsm");
FSM_Tables itables = generate_int_table();
render_fsm_table(file, itables, "int_fsm");
begin_table(file, "char", "multiline_state_table");
for (unsigned char state = 0; state < LS_count; ++state){
do_table_item(file, (state == LS_string_multiline || state == LS_char_multiline));
}
end_row(file);
end_table(file);
for (int i = 0; i < ArrayCount(pp_names); ++i){
assert(i == pp_names[i].pp_state);
FSM_Tables tables = generate_fsm_table(pp_names[i].pp_state);