another small indent rule improvement
This commit is contained in:
parent
a09851af12
commit
2f572ee72b
13
4ed.cpp
13
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
|
||||||
|
@ -472,8 +469,8 @@ COMMAND_DECL(word_complete){
|
||||||
|
|
||||||
// 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){
|
||||||
|
@ -532,7 +529,7 @@ COMMAND_DECL(word_complete){
|
||||||
|
|
||||||
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;
|
||||||
|
@ -568,11 +565,11 @@ COMMAND_DECL(word_complete){
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -906,7 +906,6 @@ file_first_lex_parallel(System_Functions *system,
|
||||||
job.callback = job_full_lex;
|
job.callback = job_full_lex;
|
||||||
job.data[0] = file;
|
job.data[0] = file;
|
||||||
job.data[1] = general;
|
job.data[1] = general;
|
||||||
job.memory_request = Kbytes(64);
|
|
||||||
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -999,7 +998,6 @@ file_relex_parallel(System_Functions *system,
|
||||||
job.callback = job_full_lex;
|
job.callback = job_full_lex;
|
||||||
job.data[0] = file;
|
job.data[0] = file;
|
||||||
job.data[1] = general;
|
job.data[1] = general;
|
||||||
job.memory_request = Kbytes(64);
|
|
||||||
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
file->state.lex_job = system->post_job(BACKGROUND_THREADS, job);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2584,8 +2582,10 @@ compute_this_indent(Buffer *buffer, Indent_Parse_State indent,
|
||||||
next_line_start = buffer_size(buffer);
|
next_line_start = buffer_size(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prev_token.type == CPP_TOKEN_COMMENT || prev_token.type == CPP_TOKEN_STRING_CONSTANT) &&
|
if ((prev_token.type == CPP_TOKEN_COMMENT ||
|
||||||
prev_token.start <= this_line_start && prev_token.start + prev_token.size > this_line_start){
|
prev_token.type == CPP_TOKEN_STRING_CONSTANT) &&
|
||||||
|
prev_token.start <= this_line_start &&
|
||||||
|
prev_token.start + prev_token.size > this_line_start){
|
||||||
this_indent = previous_indent;
|
this_indent = previous_indent;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -2620,11 +2620,13 @@ compute_this_indent(Buffer *buffer, Indent_Parse_State indent,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (indent.paren_nesting > 0){
|
if (indent.paren_nesting > 0){
|
||||||
i32 level = indent.paren_nesting-1;
|
if (prev_token.type != CPP_TOKEN_PARENTHESE_OPEN){
|
||||||
if (level >= ArrayCount(indent.paren_anchor_indent)){
|
i32 level = indent.paren_nesting-1;
|
||||||
level = ArrayCount(indent.paren_anchor_indent)-1;
|
if (level >= ArrayCount(indent.paren_anchor_indent)){
|
||||||
|
level = ArrayCount(indent.paren_anchor_indent)-1;
|
||||||
|
}
|
||||||
|
this_indent = indent.paren_anchor_indent[level];
|
||||||
}
|
}
|
||||||
this_indent = indent.paren_anchor_indent[level];
|
|
||||||
}
|
}
|
||||||
return(this_indent);
|
return(this_indent);
|
||||||
}
|
}
|
||||||
|
@ -2726,6 +2728,7 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
|
||||||
switch (token->type){
|
switch (token->type){
|
||||||
case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break;
|
case CPP_TOKEN_BRACKET_OPEN: indent.current_indent += tab_width; break;
|
||||||
case CPP_TOKEN_BRACE_OPEN: indent.current_indent += tab_width; break;
|
case CPP_TOKEN_BRACE_OPEN: indent.current_indent += tab_width; break;
|
||||||
|
case CPP_TOKEN_PARENTHESE_OPEN: indent.current_indent += tab_width; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
indent.previous_line_indent = indent.current_indent;
|
indent.previous_line_indent = indent.current_indent;
|
||||||
|
@ -2755,6 +2758,18 @@ get_line_indentation_marks(Partition *part, Buffer *buffer, Cpp_Token_Stack toke
|
||||||
// to directly passing in next_line_start and this_line_start.
|
// to directly passing in next_line_start and this_line_start.
|
||||||
i32 this_indent = compute_this_indent(buffer, indent, T, prev_token, line_i, tab_width);
|
i32 this_indent = compute_this_indent(buffer, indent, T, prev_token, line_i, tab_width);
|
||||||
|
|
||||||
|
// NOTE(allen): Rebase the paren anchor if the first token
|
||||||
|
// after an open paren is on the next line.
|
||||||
|
if (indent.paren_nesting > 0){
|
||||||
|
if (prev_token.type == CPP_TOKEN_PARENTHESE_OPEN){
|
||||||
|
i32 level = indent.paren_nesting-1;
|
||||||
|
if (level >= ArrayCount(indent.paren_anchor_indent)){
|
||||||
|
level = ArrayCount(indent.paren_anchor_indent)-1;
|
||||||
|
}
|
||||||
|
indent.paren_anchor_indent[level] = this_indent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (line_i >= line_start){
|
if (line_i >= line_start){
|
||||||
indent_marks[line_i] = this_indent;
|
indent_marks[line_i] = this_indent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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