another small indent rule improvement
This commit is contained in:
parent
a09851af12
commit
2f572ee72b
67
4ed.cpp
67
4ed.cpp
|
@ -155,9 +155,6 @@ do_feedback_message(System_Functions *system, Models *models, String value){
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
|
||||||
// TODO(allen): MOVE THIS TO models
|
|
||||||
//globalvar Application_Links app_links;
|
|
||||||
|
|
||||||
#define USE_MODELS(n) Models *n = command->models
|
#define USE_MODELS(n) Models *n = command->models
|
||||||
#define USE_VARS(n) App_Vars *n = command->vars
|
#define USE_VARS(n) App_Vars *n = command->vars
|
||||||
#define USE_PANEL(n) Panel *n = command->panel
|
#define USE_PANEL(n) Panel *n = command->panel
|
||||||
|
@ -428,52 +425,52 @@ COMMAND_DECL(word_complete){
|
||||||
USE_VARS(vars);
|
USE_VARS(vars);
|
||||||
REQ_OPEN_VIEW(view);
|
REQ_OPEN_VIEW(view);
|
||||||
REQ_FILE(file, view);
|
REQ_FILE(file, view);
|
||||||
|
|
||||||
Partition *part = &models->mem.part;
|
Partition *part = &models->mem.part;
|
||||||
General_Memory *general = &models->mem.general;
|
General_Memory *general = &models->mem.general;
|
||||||
Working_Set *working_set = &models->working_set;
|
Working_Set *working_set = &models->working_set;
|
||||||
Complete_State *complete_state = &vars->complete_state;
|
Complete_State *complete_state = &vars->complete_state;
|
||||||
Search_Range *ranges;
|
Search_Range *ranges;
|
||||||
Search_Match match;
|
Search_Match match;
|
||||||
|
|
||||||
Temp_Memory temp;
|
Temp_Memory temp;
|
||||||
|
|
||||||
Buffer_Type *buffer;
|
Buffer_Type *buffer;
|
||||||
Buffer_Backify_Type loop;
|
Buffer_Backify_Type loop;
|
||||||
char *data;
|
char *data;
|
||||||
i32 end;
|
i32 end;
|
||||||
i32 size_of_buffer;
|
i32 size_of_buffer;
|
||||||
|
|
||||||
i32 cursor_pos, word_start, word_end;
|
i32 cursor_pos, word_start, word_end;
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
char *spare;
|
char *spare;
|
||||||
i32 size;
|
i32 size;
|
||||||
|
|
||||||
i32 match_size;
|
i32 match_size;
|
||||||
b32 do_init = 0;
|
b32 do_init = 0;
|
||||||
|
|
||||||
buffer = &file->state.buffer;
|
buffer = &file->state.buffer;
|
||||||
size_of_buffer = buffer_size(buffer);
|
size_of_buffer = buffer_size(buffer);
|
||||||
|
|
||||||
if (view->mode.rewrite != 2){
|
if (view->mode.rewrite != 2){
|
||||||
do_init = 1;
|
do_init = 1;
|
||||||
}
|
}
|
||||||
view->next_mode.rewrite = 2;
|
view->next_mode.rewrite = 2;
|
||||||
|
|
||||||
if (complete_state->initialized == 0){
|
if (complete_state->initialized == 0){
|
||||||
do_init = 1;
|
do_init = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (do_init){
|
if (do_init){
|
||||||
word_end = view->recent->cursor.pos;
|
word_end = view->recent->cursor.pos;
|
||||||
word_start = word_end;
|
word_start = word_end;
|
||||||
cursor_pos = word_end - 1;
|
cursor_pos = word_end - 1;
|
||||||
|
|
||||||
// TODO(allen): macros for these buffer loops and some method of breaking out of them.
|
// TODO(allen): macros for these buffer loops and some method of breaking out of them.
|
||||||
for (loop = buffer_backify_loop(buffer, cursor_pos, 0);
|
for (loop = buffer_backify_loop(buffer, cursor_pos, 0);
|
||||||
buffer_backify_good(&loop);
|
buffer_backify_good(&loop);
|
||||||
buffer_backify_next(&loop)){
|
buffer_backify_next(&loop)){
|
||||||
end = loop.absolute_pos;
|
end = loop.absolute_pos;
|
||||||
data = loop.data - loop.absolute_pos;
|
data = loop.data - loop.absolute_pos;
|
||||||
for (; cursor_pos >= end; --cursor_pos){
|
for (; cursor_pos >= end; --cursor_pos){
|
||||||
|
@ -487,35 +484,35 @@ COMMAND_DECL(word_complete){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
double_break:;
|
double_break:;
|
||||||
|
|
||||||
size = word_end - word_start;
|
size = word_end - word_start;
|
||||||
|
|
||||||
if (size == 0){
|
if (size == 0){
|
||||||
complete_state->initialized = 0;
|
complete_state->initialized = 0;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
complete_state->initialized = 1;
|
complete_state->initialized = 1;
|
||||||
search_iter_init(general, &complete_state->iter, size);
|
search_iter_init(general, &complete_state->iter, size);
|
||||||
buffer_stringify(buffer, word_start, word_end, complete_state->iter.word.str);
|
buffer_stringify(buffer, word_start, word_end, complete_state->iter.word.str);
|
||||||
complete_state->iter.word.size = size;
|
complete_state->iter.word.size = size;
|
||||||
|
|
||||||
{
|
{
|
||||||
File_Node *node, *used_nodes;
|
File_Node *node, *used_nodes;
|
||||||
Editing_File *file_ptr;
|
Editing_File *file_ptr;
|
||||||
i32 buffer_count, j;
|
i32 buffer_count, j;
|
||||||
|
|
||||||
buffer_count = working_set->file_count;
|
buffer_count = working_set->file_count;
|
||||||
search_set_init(general, &complete_state->set, buffer_count + 1);
|
search_set_init(general, &complete_state->set, buffer_count + 1);
|
||||||
ranges = complete_state->set.ranges;
|
ranges = complete_state->set.ranges;
|
||||||
ranges[0].buffer = buffer;
|
ranges[0].buffer = buffer;
|
||||||
ranges[0].start = 0;
|
ranges[0].start = 0;
|
||||||
ranges[0].size = word_start;
|
ranges[0].size = word_start;
|
||||||
|
|
||||||
ranges[1].buffer = buffer;
|
ranges[1].buffer = buffer;
|
||||||
ranges[1].start = word_end;
|
ranges[1].start = word_end;
|
||||||
ranges[1].size = size_of_buffer - word_end;
|
ranges[1].size = size_of_buffer - word_end;
|
||||||
|
|
||||||
used_nodes = &working_set->used_sentinel;
|
used_nodes = &working_set->used_sentinel;
|
||||||
j = 2;
|
j = 2;
|
||||||
for (dll_items(node, used_nodes)){
|
for (dll_items(node, used_nodes)){
|
||||||
|
@ -529,11 +526,11 @@ COMMAND_DECL(word_complete){
|
||||||
}
|
}
|
||||||
complete_state->set.count = j;
|
complete_state->set.count = j;
|
||||||
}
|
}
|
||||||
|
|
||||||
search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4));
|
search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4));
|
||||||
search_hit_add(general, &complete_state->hits, &complete_state->str,
|
search_hit_add(general, &complete_state->hits, &complete_state->str,
|
||||||
complete_state->iter.word.str, complete_state->iter.word.size);
|
complete_state->iter.word.str, complete_state->iter.word.size);
|
||||||
|
|
||||||
complete_state->word_start = word_start;
|
complete_state->word_start = word_start;
|
||||||
complete_state->word_end = word_end;
|
complete_state->word_end = word_end;
|
||||||
}
|
}
|
||||||
|
@ -542,20 +539,20 @@ COMMAND_DECL(word_complete){
|
||||||
word_end = complete_state->word_end;
|
word_end = complete_state->word_end;
|
||||||
size = complete_state->iter.word.size;
|
size = complete_state->iter.word.size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (size > 0){
|
if (size > 0){
|
||||||
for (;;){
|
for (;;){
|
||||||
match = search_next_match(part, &complete_state->set, &complete_state->iter);
|
match = search_next_match(part, &complete_state->set, &complete_state->iter);
|
||||||
|
|
||||||
if (match.found_match){
|
if (match.found_match){
|
||||||
temp = begin_temp_memory(part);
|
temp = begin_temp_memory(part);
|
||||||
match_size = match.end - match.start;
|
match_size = match.end - match.start;
|
||||||
spare = (char*)push_array(part, char, match_size);
|
spare = (char*)push_array(part, char, match_size);
|
||||||
buffer_stringify(match.buffer, match.start, match.end, spare);
|
buffer_stringify(match.buffer, match.start, match.end, spare);
|
||||||
|
|
||||||
if (search_hit_add(general, &complete_state->hits, &complete_state->str, spare, match_size)){
|
if (search_hit_add(general, &complete_state->hits, &complete_state->str, spare, match_size)){
|
||||||
view_replace_range(system, models, view, word_start, word_end, spare, match_size, word_end);
|
view_replace_range(system, models, view, word_start, word_end, spare, match_size, word_end);
|
||||||
|
|
||||||
complete_state->word_end = word_start + match_size;
|
complete_state->word_end = word_start + match_size;
|
||||||
complete_state->set.ranges[1].start = word_start + match_size;
|
complete_state->set.ranges[1].start = word_start + match_size;
|
||||||
break;
|
break;
|
||||||
|
@ -565,15 +562,15 @@ COMMAND_DECL(word_complete){
|
||||||
else{
|
else{
|
||||||
complete_state->iter.pos = 0;
|
complete_state->iter.pos = 0;
|
||||||
complete_state->iter.i = 0;
|
complete_state->iter.i = 0;
|
||||||
|
|
||||||
search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4));
|
search_hits_init(general, &complete_state->hits, &complete_state->str, 100, Kbytes(4));
|
||||||
search_hit_add(general, &complete_state->hits, &complete_state->str,
|
search_hit_add(general, &complete_state->hits, &complete_state->str,
|
||||||
complete_state->iter.word.str, complete_state->iter.word.size);
|
complete_state->iter.word.str, complete_state->iter.word.size);
|
||||||
|
|
||||||
match_size = complete_state->iter.word.size;
|
match_size = complete_state->iter.word.size;
|
||||||
view_replace_range(system, models, view, word_start, word_end,
|
view_replace_range(system, models, view, word_start, word_end,
|
||||||
complete_state->iter.word.str, match_size, word_end);
|
complete_state->iter.word.str, match_size, word_end);
|
||||||
|
|
||||||
complete_state->word_end = word_start + match_size;
|
complete_state->word_end = word_start + match_size;
|
||||||
complete_state->set.ranges[1].start = word_start + match_size;
|
complete_state->set.ranges[1].start = word_start + match_size;
|
||||||
break;
|
break;
|
||||||
|
|
11311
4ed_file_view.cpp
11311
4ed_file_view.cpp
File diff suppressed because it is too large
Load Diff
|
@ -167,7 +167,7 @@ typedef Job_Callback_Sig(Job_Callback);
|
||||||
struct Job_Data{
|
struct Job_Data{
|
||||||
Job_Callback *callback;
|
Job_Callback *callback;
|
||||||
void *data[2];
|
void *data[2];
|
||||||
i32 memory_request;
|
//i32 memory_request;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Full_Job_Data{
|
struct Full_Job_Data{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates.
|
// NOTE(allen): This is an experiment, BUT remember a lot of people shit on templates.
|
||||||
// So if you start getting a wiff of stupidity from this back out immediately!
|
// So if you start getting a wiff of stupidity from this back out immediately!
|
||||||
//
|
//
|
||||||
// experience 1: no badness, haven't seen any anoying template errors
|
// experience 1: no badness, haven't seen any annoying template errors
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
|
13
TODO.txt
13
TODO.txt
|
@ -190,15 +190,24 @@
|
||||||
|
|
||||||
; HARD BUGS
|
; HARD BUGS
|
||||||
; [X] reduce cpu consumption
|
; [X] reduce cpu consumption
|
||||||
; [?] minimize and reopen problem (reported by two users now, still not reproduced here)
|
|
||||||
; [X] repainting too slow for resize looks really dumb
|
; [X] repainting too slow for resize looks really dumb
|
||||||
; [] fyoucon's segfaults with malloc on win10
|
; [] fyoucon's segfaults with malloc on win10
|
||||||
; [] handling cursor in non-client part of window so it doesn't spaz
|
; [] handling cursor in non-client part of window so it doesn't spaz
|
||||||
; [] fill screen right away
|
; [] fill screen right away
|
||||||
; [] how to get fast repaint (do I really need double buffering?)
|
; [] how to get fast repaint (do I really need double buffering?)
|
||||||
; [] history breaks when heavily used (disk swaping?)
|
; [] history breaks when heavily used (disk swaping?)
|
||||||
; [] window stops repainting bug on a handful of machines (Win 10? Driver?)
|
|
||||||
;
|
;
|
||||||
|
; [] minimize and reopen problem (reported by two users now, still not reproduced here)
|
||||||
|
;
|
||||||
|
|
||||||
|
; FANCY PANTS IDEAS
|
||||||
|
; [] pass messages to 'jobs' to try to avoid cancelling them
|
||||||
|
; if the job still thinks it should be cancelled it will say so
|
||||||
|
; but otherwise the job can try to incorporate the new info
|
||||||
|
; without throwing away the progress it has made so far.
|
||||||
|
;
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
; PORTING TODOS
|
; PORTING TODOS
|
||||||
; [X] command line parameters
|
; [X] command line parameters
|
||||||
|
|
|
@ -319,6 +319,14 @@ JobThreadProc(LPVOID lpParameter){
|
||||||
i32 cancel_lock = group->cancel_lock0 + thread_index;
|
i32 cancel_lock = group->cancel_lock0 + thread_index;
|
||||||
i32 cancel_cv = group->cancel_cv0 + thread_index;
|
i32 cancel_cv = group->cancel_cv0 + thread_index;
|
||||||
|
|
||||||
|
Thread_Memory *thread_memory = win32vars.thread_memory + thread_index;
|
||||||
|
|
||||||
|
if (thread_memory->size == 0){
|
||||||
|
i32 new_size = Kbytes(64);
|
||||||
|
thread_memory->data = Win32GetMemory(new_size);
|
||||||
|
thread_memory->size = new_size;
|
||||||
|
}
|
||||||
|
|
||||||
for (;;){
|
for (;;){
|
||||||
u32 read_index = queue->read_position;
|
u32 read_index = queue->read_position;
|
||||||
u32 write_index = queue->write_position;
|
u32 write_index = queue->write_position;
|
||||||
|
@ -342,20 +350,7 @@ JobThreadProc(LPVOID lpParameter){
|
||||||
if (safe_running_thread == THREAD_NOT_ASSIGNED){
|
if (safe_running_thread == THREAD_NOT_ASSIGNED){
|
||||||
thread->job_id = full_job->id;
|
thread->job_id = full_job->id;
|
||||||
thread->running = 1;
|
thread->running = 1;
|
||||||
Thread_Memory *thread_memory = 0;
|
|
||||||
|
|
||||||
// TODO(allen): remove memory_request
|
|
||||||
if (full_job->job.memory_request != 0){
|
|
||||||
thread_memory = win32vars.thread_memory + thread->id - 1;
|
|
||||||
if (thread_memory->size < full_job->job.memory_request){
|
|
||||||
if (thread_memory->data){
|
|
||||||
Win32FreeMemory(thread_memory->data);
|
|
||||||
}
|
|
||||||
i32 new_size = LargeRoundUp(full_job->job.memory_request, Kbytes(4));
|
|
||||||
thread_memory->data = Win32GetMemory(new_size);
|
|
||||||
thread_memory->size = new_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
full_job->job.callback(&win32vars.system,
|
full_job->job.callback(&win32vars.system,
|
||||||
thread, thread_memory, full_job->job.data);
|
thread, thread_memory, full_job->job.data);
|
||||||
PostMessage(win32vars.window_handle, WM_4coder_ANIMATE, 0, 0);
|
PostMessage(win32vars.window_handle, WM_4coder_ANIMATE, 0, 0);
|
||||||
|
@ -1699,6 +1694,27 @@ WinMain(HINSTANCE hInstance,
|
||||||
// Threads and Coroutines
|
// Threads and Coroutines
|
||||||
//
|
//
|
||||||
|
|
||||||
|
// NOTE(allen): These should come before threads are started!
|
||||||
|
// Threads now get memory right away and so they use
|
||||||
|
// the internal_bubble and DEBUG_sysmem_lock
|
||||||
|
|
||||||
|
#if FRED_INTERNAL
|
||||||
|
win32vars.internal_bubble.next = &win32vars.internal_bubble;
|
||||||
|
win32vars.internal_bubble.prev = &win32vars.internal_bubble;
|
||||||
|
win32vars.internal_bubble.flags = MEM_BUBBLE_SYS_DEBUG;
|
||||||
|
|
||||||
|
InitializeCriticalSection(&win32vars.DEBUG_sysmem_lock);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i32 i = 0; i < LOCK_COUNT; ++i){
|
||||||
|
InitializeCriticalSection(&win32vars.locks[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i32 i = 0; i < CV_COUNT; ++i){
|
||||||
|
InitializeConditionVariable(&win32vars.condition_vars[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Thread_Context background[4];
|
Thread_Context background[4];
|
||||||
memset(background, 0, sizeof(background));
|
memset(background, 0, sizeof(background));
|
||||||
win32vars.groups[BACKGROUND_THREADS].threads = background;
|
win32vars.groups[BACKGROUND_THREADS].threads = background;
|
||||||
|
@ -1728,12 +1744,6 @@ WinMain(HINSTANCE hInstance,
|
||||||
thread->handle = CreateThread(0, 0, JobThreadProc, thread, creation_flag, (LPDWORD)&thread->windows_id);
|
thread->handle = CreateThread(0, 0, JobThreadProc, thread, creation_flag, (LPDWORD)&thread->windows_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert(win32vars.locks);
|
|
||||||
for (i32 i = 0; i < LOCK_COUNT; ++i){
|
|
||||||
InitializeCriticalSection(&win32vars.locks[i]);
|
|
||||||
}
|
|
||||||
InitializeCriticalSection(&win32vars.DEBUG_sysmem_lock);
|
|
||||||
|
|
||||||
ConvertThreadToFiber(0);
|
ConvertThreadToFiber(0);
|
||||||
win32vars.coroutine_free = win32vars.coroutine_data;
|
win32vars.coroutine_free = win32vars.coroutine_data;
|
||||||
for (i32 i = 0; i+1 < ArrayCount(win32vars.coroutine_data); ++i){
|
for (i32 i = 0; i+1 < ArrayCount(win32vars.coroutine_data); ++i){
|
||||||
|
@ -1745,12 +1755,6 @@ WinMain(HINSTANCE hInstance,
|
||||||
// Memory Initialization
|
// Memory Initialization
|
||||||
//
|
//
|
||||||
|
|
||||||
#if FRED_INTERNAL
|
|
||||||
win32vars.internal_bubble.next = &win32vars.internal_bubble;
|
|
||||||
win32vars.internal_bubble.prev = &win32vars.internal_bubble;
|
|
||||||
win32vars.internal_bubble.flags = MEM_BUBBLE_SYS_DEBUG;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LPVOID base;
|
LPVOID base;
|
||||||
#if FRED_INTERNAL
|
#if FRED_INTERNAL
|
||||||
base = (LPVOID)Tbytes(1);
|
base = (LPVOID)Tbytes(1);
|
||||||
|
|
Loading…
Reference in New Issue