part of the way towards adding an apparent-character positioning system, need the metadata for it now
This commit is contained in:
parent
df5535cc87
commit
ac2a3ffb6d
355
4coder_API.html
355
4coder_API.html
File diff suppressed because one or more lines are too long
|
@ -593,8 +593,8 @@ buffer_auto_indent(Application_Links *app, Partition *part, Buffer_Summary *buff
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool32
|
static bool32
|
||||||
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer,
|
buffer_auto_indent(Application_Links *app, Buffer_Summary *buffer, int32_t start, int32_t end,
|
||||||
int32_t start, int32_t end, int32_t tab_width, Auto_Indent_Flag flags){
|
int32_t tab_width, Auto_Indent_Flag flags){
|
||||||
bool32 result = buffer_auto_indent(app, &global_part, buffer, start, end, tab_width, flags);
|
bool32 result = buffer_auto_indent(app, &global_part, buffer, start, end, tab_width, flags);
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,9 +120,8 @@ static General_Memory global_general;
|
||||||
|
|
||||||
void
|
void
|
||||||
init_memory(Application_Links *app){
|
init_memory(Application_Links *app){
|
||||||
int32_t part_size = (1 << 20);
|
int32_t part_size = (32 << 20);
|
||||||
int32_t general_size = (1 << 20);
|
int32_t general_size = (4 << 20);
|
||||||
|
|
||||||
|
|
||||||
void *part_mem = memory_allocate(app, part_size);
|
void *part_mem = memory_allocate(app, part_size);
|
||||||
global_part = make_part(part_mem, part_size);
|
global_part = make_part(part_mem, part_size);
|
||||||
|
@ -733,22 +732,26 @@ CUSTOM_COMMAND_SIG(write_character){
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int32_t pos = view.cursor.pos;
|
int32_t pos = view.cursor.pos;
|
||||||
int32_t next_pos = pos + 1;
|
buffer_replace_range(app, &buffer, pos, pos, &character, 1);
|
||||||
buffer_replace_range(app, &buffer,
|
view_set_cursor(app, &view, seek_pos(view.cursor.character_pos + 1), true);
|
||||||
pos, pos, &character, 1);
|
|
||||||
view_set_cursor(app, &view, seek_pos(next_pos), true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(delete_char){
|
CUSTOM_COMMAND_SIG(delete_char){
|
||||||
uint32_t access = AccessOpen;
|
uint32_t access = AccessOpen;
|
||||||
View_Summary view = get_active_view(app, access);
|
View_Summary view = get_active_view(app, access);
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int32_t pos = view.cursor.pos;
|
int32_t start = view.cursor.pos;
|
||||||
if (0 < buffer.size && pos < buffer.size){
|
|
||||||
buffer_replace_range(app, &buffer,
|
Partial_Cursor cursor;
|
||||||
pos, pos+1, 0, 0);
|
buffer_compute_cursor(app, &buffer, seek_character_pos(view.cursor.character_pos+1), &cursor);
|
||||||
|
int32_t end = cursor.pos;
|
||||||
|
|
||||||
|
if (0 <= start && start < buffer.size){
|
||||||
|
buffer_replace_range(app, &buffer, start, end, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -757,12 +760,15 @@ CUSTOM_COMMAND_SIG(backspace_char){
|
||||||
View_Summary view = get_active_view(app, access);
|
View_Summary view = get_active_view(app, access);
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int32_t pos = view.cursor.pos;
|
int32_t end = view.cursor.pos;
|
||||||
if (0 < pos && pos <= buffer.size){
|
|
||||||
buffer_replace_range(app, &buffer,
|
Partial_Cursor cursor;
|
||||||
pos-1, pos, 0, 0);
|
buffer_compute_cursor(app, &buffer, seek_character_pos(view.cursor.character_pos-1), &cursor);
|
||||||
|
int32_t start = cursor.pos;
|
||||||
view_set_cursor(app, &view, seek_pos(pos-1), true);
|
|
||||||
|
if (0 < end && end <= buffer.size){
|
||||||
|
buffer_replace_range(app, &buffer, start, end, 0, 0);
|
||||||
|
view_set_cursor(app, &view, seek_character_pos(view.cursor.character_pos-1), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -771,8 +777,7 @@ CUSTOM_COMMAND_SIG(set_mark){
|
||||||
View_Summary view = get_active_view(app, access);
|
View_Summary view = get_active_view(app, access);
|
||||||
|
|
||||||
view_set_mark(app, &view, seek_pos(view.cursor.pos));
|
view_set_mark(app, &view, seek_pos(view.cursor.pos));
|
||||||
// TODO(allen): Just expose the preferred_x seperately
|
view_set_cursor(app, &view, seek_pos(view.cursor.pos), 1);
|
||||||
view_set_cursor(app, &view, seek_pos(view.cursor.pos), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(cursor_mark_swap){
|
CUSTOM_COMMAND_SIG(cursor_mark_swap){
|
||||||
|
@ -792,10 +797,7 @@ CUSTOM_COMMAND_SIG(delete_range){
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
Range range = get_range(&view);
|
Range range = get_range(&view);
|
||||||
|
buffer_replace_range(app, &buffer, range.min, range.max, 0, 0);
|
||||||
buffer_replace_range(app, &buffer,
|
|
||||||
range.min, range.max,
|
|
||||||
0, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
|
@ -212,8 +212,7 @@ end_bind_helper(Bind_Helper *helper){
|
||||||
|
|
||||||
inline Range
|
inline Range
|
||||||
get_range(View_Summary *view){
|
get_range(View_Summary *view){
|
||||||
Range range;
|
Range range = make_range(view->cursor.pos, view->mark.pos);
|
||||||
range = make_range(view->cursor.pos, view->mark.pos);
|
|
||||||
return(range);
|
return(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,14 @@ seek_pos(int32_t pos){
|
||||||
return(result);
|
return(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static Buffer_Seek
|
||||||
|
seek_character_pos(int32_t pos){
|
||||||
|
Buffer_Seek result;
|
||||||
|
result.type = buffer_seek_character_pos;
|
||||||
|
result.pos = pos;
|
||||||
|
return(result);
|
||||||
|
}
|
||||||
|
|
||||||
static Buffer_Seek
|
static Buffer_Seek
|
||||||
seek_wrapped_xy(float x, float y, int32_t round_down){
|
seek_wrapped_xy(float x, float y, int32_t round_down){
|
||||||
Buffer_Seek result;
|
Buffer_Seek result;
|
||||||
|
|
109
4coder_types.h
109
4coder_types.h
|
@ -322,22 +322,6 @@ ENUM(int32_t, Mouse_Cursor_Show_Type){
|
||||||
// MouseCursorShow_WhenActive,// TODO(allen): coming soon
|
// MouseCursorShow_WhenActive,// TODO(allen): coming soon
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which
|
|
||||||
coordinates are suppose to be used for the seek.)
|
|
||||||
DOC_SEE(Buffer_Seek)
|
|
||||||
DOC_SEE(4coder_Buffer_Positioning_System)
|
|
||||||
*/
|
|
||||||
ENUM(int32_t, Buffer_Seek_Type){
|
|
||||||
/* DOC(This value indicates absolute positioning where positions are measured as the number of bytes from the start of the file.) */
|
|
||||||
buffer_seek_pos,
|
|
||||||
/* DOC(This value indicates xy positioning with wrapped lines where the x and y values are in pixels.) */
|
|
||||||
buffer_seek_wrapped_xy,
|
|
||||||
/* DOC(This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.) */
|
|
||||||
buffer_seek_unwrapped_xy,
|
|
||||||
/* DOC(This value indicates line-character, or line-column positioning. These coordinates are 1 based to match standard line numbering.) */
|
|
||||||
buffer_seek_line_char
|
|
||||||
};
|
|
||||||
|
|
||||||
/* DOC(A View_Split_Position specifies where a new view should be placed as a result of
|
/* DOC(A View_Split_Position specifies where a new view should be placed as a result of
|
||||||
a view split operation.) */
|
a view split operation.) */
|
||||||
ENUM(int32_t, View_Split_Position){
|
ENUM(int32_t, View_Split_Position){
|
||||||
|
@ -504,39 +488,25 @@ struct GUI_Scroll_Vars{
|
||||||
int32_t prev_target_x;
|
int32_t prev_target_x;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(Full_Cursor describes the position of a cursor in every buffer
|
/* DOC(The Buffer_Seek_Type is is used in a Buffer_Seek to identify which
|
||||||
coordinate system supported by 4coder. This cursor type requires that
|
coordinates are suppose to be used for the seek.)
|
||||||
the buffer is associated with a view to give the x/y values meaning.)
|
DOC_SEE(Buffer_Seek)
|
||||||
DOC_SEE(4coder_Buffer_Positioning_System) */
|
DOC_SEE(4coder_Buffer_Positioning_System)
|
||||||
struct Full_Cursor{
|
*/
|
||||||
/* DOC(This field contains the cursor's position in absolute positioning.) */
|
ENUM(int32_t, Buffer_Seek_Type){
|
||||||
int32_t pos;
|
/* DOC(This value indicates absolute byte index positioning
|
||||||
/* DOC(This field contains the number of the line where the cursor is located. This field is one based.) */
|
where positions are measured as the number of bytes from the start of the file.) */
|
||||||
int32_t line;
|
buffer_seek_pos,
|
||||||
/* DOC(This field contains the number of the column where the cursor is located. This field is one based.) */
|
/* DOC(This value indicates apparent character index positioning
|
||||||
int32_t character;
|
where positions are measured as the number of apparent characters from the starts of the file.) */
|
||||||
/* DOC(This field contains the x position measured with unwrapped lines.) */
|
buffer_seek_character_pos,
|
||||||
float unwrapped_x;
|
/* DOC(This value indicates xy positioning with wrapped lines where the x and y values are in pixels.) */
|
||||||
/* DOC(This field contains the y position measured with unwrapped lines.) */
|
buffer_seek_wrapped_xy,
|
||||||
float unwrapped_y;
|
/* DOC(This value indicates xy positioning with unwrapped lines where the x and y values are in pixels.) */
|
||||||
/* DOC(This field contains the x position measured with wrapped lines.) */
|
buffer_seek_unwrapped_xy,
|
||||||
float wrapped_x;
|
/* DOC(This value indicates line-character positioning.
|
||||||
/* DOC(This field contains the y position measured with wrapped lines.) */
|
These coordinates are 1 based to match standard line numbering.) */
|
||||||
float wrapped_y;
|
buffer_seek_line_char
|
||||||
};
|
|
||||||
|
|
||||||
/* DOC(Partial_Cursor describes the position of a cursor in all of
|
|
||||||
the coordinate systems that a invariant to the View. In other words
|
|
||||||
the coordinate systems available here can be used on a buffer that is
|
|
||||||
not currently associated with a View.)
|
|
||||||
DOC_SEE(4coder_Buffer_Positioning_System) */
|
|
||||||
struct Partial_Cursor{
|
|
||||||
/* DOC(This field contains the cursor's position in absolute positioning.) */
|
|
||||||
int32_t pos;
|
|
||||||
/* DOC(This field contains the number of the line where the cursor is located. This field is one based.) */
|
|
||||||
int32_t line;
|
|
||||||
/* DOC(This field contains the number of the column where the cursor is located. This field is one based.) */
|
|
||||||
int32_t character;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* DOC(Buffer_Seek describes the destination of a seek operation. There are helpers
|
/* DOC(Buffer_Seek describes the destination of a seek operation. There are helpers
|
||||||
|
@ -573,6 +543,47 @@ struct Buffer_Seek{
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* DOC(Full_Cursor describes the position of a cursor in every buffer
|
||||||
|
coordinate system supported by 4coder. This cursor type requires that
|
||||||
|
the buffer is associated with a view to give the x/y values meaning.)
|
||||||
|
DOC_SEE(4coder_Buffer_Positioning_System) */
|
||||||
|
struct Full_Cursor{
|
||||||
|
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
|
||||||
|
int32_t pos;
|
||||||
|
/* DOC(This field contains the cursor's position in apparent character index positioning.) */
|
||||||
|
int32_t character_pos;
|
||||||
|
/* DOC(This field contains the number of the line where the cursor is located. This field is one based.) */
|
||||||
|
int32_t line;
|
||||||
|
/* DOC(This field contains the number of the character from the beginninf of the line
|
||||||
|
where the cursor is located. This field is one based.) */
|
||||||
|
int32_t character;
|
||||||
|
/* DOC(This field contains the x position measured with unwrapped lines.) */
|
||||||
|
float unwrapped_x;
|
||||||
|
/* DOC(This field contains the y position measured with unwrapped lines.) */
|
||||||
|
float unwrapped_y;
|
||||||
|
/* DOC(This field contains the x position measured with wrapped lines.) */
|
||||||
|
float wrapped_x;
|
||||||
|
/* DOC(This field contains the y position measured with wrapped lines.) */
|
||||||
|
float wrapped_y;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* DOC(Partial_Cursor describes the position of a cursor in all of
|
||||||
|
the coordinate systems that a invariant to the View. In other words
|
||||||
|
the coordinate systems available here can be used on a buffer that is
|
||||||
|
not currently associated with a View.)
|
||||||
|
DOC_SEE(4coder_Buffer_Positioning_System) */
|
||||||
|
struct Partial_Cursor{
|
||||||
|
/* DOC(This field contains the cursor's position in absolute byte index positioning.) */
|
||||||
|
int32_t pos;
|
||||||
|
/* DOC(This field contains the cursor's position in apparent character index positioning.) */
|
||||||
|
int32_t character_pos;
|
||||||
|
/* DOC(This field contains the number of the character from the beginninf of the line
|
||||||
|
where the cursor is located. This field is one based.) */
|
||||||
|
int32_t line;
|
||||||
|
/* DOC(This field contains the number of the column where the cursor is located. This field is one based.) */
|
||||||
|
int32_t character;
|
||||||
|
};
|
||||||
|
|
||||||
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range.
|
/* DOC(Buffer_Edit describes a range of a buffer and string to replace that range.
|
||||||
A Buffer_Edit has to be paired with a string that contains the actual text that
|
A Buffer_Edit has to be paired with a string that contains the actual text that
|
||||||
will be replaced into the buffer.) */
|
will be replaced into the buffer.) */
|
||||||
|
|
|
@ -2970,9 +2970,9 @@ generate_custom_headers(){
|
||||||
"<body>"
|
"<body>"
|
||||||
"<div style='font-family:Arial; margin: 0 auto; "
|
"<div style='font-family:Arial; margin: 0 auto; "
|
||||||
"width: 800px; text-align: justify; line-height: 1.25;'>"
|
"width: 800px; text-align: justify; line-height: 1.25;'>"
|
||||||
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4cpp Lexing Library</h1>");
|
// "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4cpp Lexing Library</h1>");
|
||||||
|
|
||||||
// "<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>");
|
"<h1 style='margin-top: 5mm; margin-bottom: 5mm;'>4coder API</h1>");
|
||||||
|
|
||||||
struct Section{
|
struct Section{
|
||||||
char *id_string;
|
char *id_string;
|
||||||
|
@ -2983,9 +2983,9 @@ generate_custom_headers(){
|
||||||
|
|
||||||
static Section sections[] = {
|
static Section sections[] = {
|
||||||
{"introduction", "Introduction"},
|
{"introduction", "Introduction"},
|
||||||
//{"4coder_systems", "4coder Systems"},
|
{"4coder_systems", "4coder Systems"},
|
||||||
//{"types_and_functions", "Types and Functions"},
|
{"types_and_functions", "Types and Functions"},
|
||||||
//{"string_library", "String Library"},
|
{"string_library", "String Library"},
|
||||||
{"lexer_library", "Lexer Library"}
|
{"lexer_library", "Lexer Library"}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3029,8 +3029,6 @@ generate_custom_headers(){
|
||||||
"</div>");
|
"</div>");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
append_sc(&out,
|
append_sc(&out,
|
||||||
"<div>"
|
"<div>"
|
||||||
"<p>This is the documentation for " VERSION " The documentation is still "
|
"<p>This is the documentation for " VERSION " The documentation is still "
|
||||||
|
@ -3159,13 +3157,6 @@ generate_custom_headers(){
|
||||||
#undef MAJOR_SECTION
|
#undef MAJOR_SECTION
|
||||||
#define MAJOR_SECTION "5"
|
#define MAJOR_SECTION "5"
|
||||||
msection = 4;
|
msection = 4;
|
||||||
#endif
|
|
||||||
|
|
||||||
(void)(unit);
|
|
||||||
|
|
||||||
#undef MAJOR_SECTION
|
|
||||||
#define MAJOR_SECTION "2"
|
|
||||||
msection = 1;
|
|
||||||
|
|
||||||
append_sc(&out, "\n<h2 id='section_");
|
append_sc(&out, "\n<h2 id='section_");
|
||||||
append_sc(&out, sections[msection].id_string);
|
append_sc(&out, sections[msection].id_string);
|
||||||
|
|
|
@ -506,6 +506,11 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
|
||||||
S.cursor = make_cursor_hint(line_index, params.buffer->line_starts, params.wraps, params.font_height);
|
S.cursor = make_cursor_hint(line_index, params.buffer->line_starts, params.wraps, params.font_height);
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
case buffer_seek_character_pos:
|
||||||
|
{
|
||||||
|
NotImplemented;
|
||||||
|
}break;
|
||||||
|
|
||||||
case buffer_seek_line_char:
|
case buffer_seek_line_char:
|
||||||
{
|
{
|
||||||
i32 line_index = params.seek.line - 1;
|
i32 line_index = params.seek.line - 1;
|
||||||
|
@ -568,7 +573,6 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
|
||||||
else{
|
else{
|
||||||
++S.cursor.character;
|
++S.cursor.character;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
S.still_looping = buffer_stringify_next(&S.stream);
|
S.still_looping = buffer_stringify_next(&S.stream);
|
||||||
}while(S.still_looping);
|
}while(S.still_looping);
|
||||||
|
@ -586,9 +590,18 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
|
case buffer_seek_character_pos:
|
||||||
|
{
|
||||||
|
if (S.cursor.character_pos >= params.seek.pos){
|
||||||
|
goto buffer_cursor_seek_end;
|
||||||
|
}
|
||||||
|
}break;
|
||||||
|
|
||||||
case buffer_seek_line_char:
|
case buffer_seek_line_char:
|
||||||
{
|
{
|
||||||
if (S.cursor.line >= params.seek.line && S.cursor.character >= params.seek.character){
|
if ((S.cursor.line == params.seek.line &&
|
||||||
|
S.cursor.character >= params.seek.character) ||
|
||||||
|
S.cursor.line > params.seek.line){
|
||||||
goto buffer_cursor_seek_end;
|
goto buffer_cursor_seek_end;
|
||||||
}
|
}
|
||||||
}break;
|
}break;
|
||||||
|
@ -643,6 +656,7 @@ buffer_cursor_seek(Buffer_Cursor_Seek_State *S_ptr, Buffer_Cursor_Seek_Params pa
|
||||||
S.prev_cursor = S.cursor;
|
S.prev_cursor = S.cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
++S.cursor.character_pos;
|
||||||
++S.cursor.character;
|
++S.cursor.character;
|
||||||
S.cursor.unwrapped_x += ch_width;
|
S.cursor.unwrapped_x += ch_width;
|
||||||
S.cursor.wrapped_x += ch_width;
|
S.cursor.wrapped_x += ch_width;
|
||||||
|
@ -980,7 +994,7 @@ buffer_render_data(Buffer_Render_State *S_ptr, Buffer_Render_Params params, f32
|
||||||
else{
|
else{
|
||||||
S.write = write_render_item(S.write, S.i, '\\', BRFlag_Special_Character);
|
S.write = write_render_item(S.write, S.i, '\\', BRFlag_Special_Character);
|
||||||
|
|
||||||
char ch = S.ch;
|
u8 ch = S.ch;
|
||||||
char C = '0' + (ch / 0x10);
|
char C = '0' + (ch / 0x10);
|
||||||
if ((ch / 0x10) > 0x9){
|
if ((ch / 0x10) > 0x9){
|
||||||
C = ('A' - 0xA) + (ch / 0x10);
|
C = ('A' - 0xA) + (ch / 0x10);
|
||||||
|
|
|
@ -192,11 +192,36 @@ CUSTOM_COMMAND_SIG(load_unicode_file){
|
||||||
view_set_cursor(app, &view, seek_line_char(230, 25), 1);
|
view_set_cursor(app, &view, seek_line_char(230, 25), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CUSTOM_COMMAND_SIG(edit_giant_file){
|
||||||
|
Buffer_Summary buffer = create_buffer(app, literal(TEST_FILES "/test_large.cpp"), 0);
|
||||||
|
View_Summary view = get_active_view(app, AccessAll);
|
||||||
|
view_set_buffer(app, &view, buffer.buffer_id, 0);
|
||||||
|
view_set_cursor(app, &view, seek_line_char(230, 25), 1);
|
||||||
|
|
||||||
|
for (int32_t i = 0; i < 600; ++i){
|
||||||
|
Query_Bar bar = {0};
|
||||||
|
bar.prompt = make_lit_string("Do something to continue the test");
|
||||||
|
if (start_query_bar(app, &bar, 0)){
|
||||||
|
get_user_input(app, EventAll, EventAll);
|
||||||
|
}
|
||||||
|
end_query_bar(app, &bar, 0);
|
||||||
|
refresh_buffer(app, &buffer);
|
||||||
|
if (buffer.tokens_are_ready){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buffer_replace_range(app, &buffer, 2000, 2000,
|
||||||
|
literal("{\n//Not important at all\n}\n"));
|
||||||
|
buffer_auto_indent(app, &buffer, 2000, 2100, 4, 0);
|
||||||
|
}
|
||||||
|
|
||||||
CUSTOM_COMMAND_SIG(run_all_tests){
|
CUSTOM_COMMAND_SIG(run_all_tests){
|
||||||
exec_command(app, load_lots_of_files);
|
exec_command(app, load_lots_of_files);
|
||||||
exec_command(app, reopen_test);
|
exec_command(app, reopen_test);
|
||||||
exec_command(app, stop_spots_test);
|
exec_command(app, stop_spots_test);
|
||||||
exec_command(app, load_unicode_file);
|
exec_command(app, load_unicode_file);
|
||||||
|
exec_command(app, edit_giant_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -18,19 +18,21 @@ CUSTOM_COMMAND_SIG(kill_rect){
|
||||||
|
|
||||||
Buffer_Rect rect = get_rect(&view);
|
Buffer_Rect rect = get_rect(&view);
|
||||||
|
|
||||||
for (int line = rect.line1; line >= rect.line0; --line){
|
for (int32_t line = rect.line1; line >= rect.line0; --line){
|
||||||
int start = 0;
|
int32_t start = 0;
|
||||||
int end = 0;
|
int32_t end = 0;
|
||||||
|
|
||||||
int success = true;
|
int32_t success = 1;
|
||||||
Full_Cursor cursor = {0};
|
Full_Cursor cursor = {0};
|
||||||
|
|
||||||
success = success &&
|
if (success){
|
||||||
view_compute_cursor(app, &view, seek_line_char(line, rect.char0), &cursor);
|
success = view_compute_cursor(app, &view, seek_line_char(line, rect.char0), &cursor);
|
||||||
|
}
|
||||||
start = cursor.pos;
|
start = cursor.pos;
|
||||||
|
|
||||||
success = success &&
|
if (success){
|
||||||
view_compute_cursor(app, &view, seek_line_char(line, rect.char1), &cursor);
|
success = view_compute_cursor(app, &view, seek_line_char(line, rect.char1), &cursor);
|
||||||
|
}
|
||||||
end = cursor.pos;
|
end = cursor.pos;
|
||||||
|
|
||||||
if (success){
|
if (success){
|
||||||
|
@ -187,19 +189,17 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
View_Summary view = get_active_view(app, access);
|
View_Summary view = get_active_view(app, access);
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int32_t start_pos = view.cursor.pos;
|
|
||||||
|
|
||||||
// NOTE(allen): The user provides the memory that the chunk uses,
|
// NOTE(allen): The user provides the memory that the chunk uses,
|
||||||
// this chunk will then be filled at each step of the text stream loop.
|
// this chunk will then be filled at each step of the text stream loop.
|
||||||
// This way you can look for something that should be nearby without
|
// This way you can look for something that should be nearby without
|
||||||
// having to copy the whole file in at once.
|
// having to copy the whole file in at once.
|
||||||
Stream_Chunk chunk;
|
Stream_Chunk chunk = {0};
|
||||||
char chunk_space[(1 << 10)];
|
char chunk_space[(1 << 10)];
|
||||||
|
|
||||||
int32_t result = 0;
|
int32_t result = 0;
|
||||||
int32_t found_result = 0;
|
int32_t found_result = 0;
|
||||||
|
|
||||||
int32_t i = start_pos;
|
int32_t i = view.cursor.pos;
|
||||||
int32_t still_looping = 1;
|
int32_t still_looping = 1;
|
||||||
int32_t nesting_counter = 0;
|
int32_t nesting_counter = 0;
|
||||||
char at_cursor = 0;
|
char at_cursor = 0;
|
||||||
|
@ -212,8 +212,9 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
// If i goes below chunk.start or above chunk.end _that_ is an invalid access.
|
// If i goes below chunk.start or above chunk.end _that_ is an invalid access.
|
||||||
at_cursor = chunk.data[i];
|
at_cursor = chunk.data[i];
|
||||||
if (at_cursor == '{'){
|
if (at_cursor == '{'){
|
||||||
|
++i;
|
||||||
do{
|
do{
|
||||||
for (++i; i < chunk.end; ++i){
|
for (; i < chunk.end; ++i){
|
||||||
at_cursor = chunk.data[i];
|
at_cursor = chunk.data[i];
|
||||||
if (at_cursor == '{'){
|
if (at_cursor == '{'){
|
||||||
++nesting_counter;
|
++nesting_counter;
|
||||||
|
@ -234,8 +235,9 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
while (still_looping);
|
while (still_looping);
|
||||||
}
|
}
|
||||||
else if (at_cursor == '}'){
|
else if (at_cursor == '}'){
|
||||||
|
--i;
|
||||||
do{
|
do{
|
||||||
for (--i; i >= chunk.start; --i){
|
for (; i >= chunk.start; --i){
|
||||||
at_cursor = chunk.data[i];
|
at_cursor = chunk.data[i];
|
||||||
if (at_cursor == '}'){
|
if (at_cursor == '}'){
|
||||||
++nesting_counter;
|
++nesting_counter;
|
||||||
|
@ -257,7 +259,7 @@ CUSTOM_COMMAND_SIG(mark_matching_brace){
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
finished:
|
finished:;
|
||||||
if (found_result){
|
if (found_result){
|
||||||
view_set_mark(app, &view, seek_pos(result+1));
|
view_set_mark(app, &view, seek_pos(result+1));
|
||||||
}
|
}
|
||||||
|
@ -268,17 +270,15 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){
|
||||||
View_Summary view = get_active_view(app, access);
|
View_Summary view = get_active_view(app, access);
|
||||||
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
Buffer_Summary buffer = get_buffer(app, view.buffer_id, access);
|
||||||
|
|
||||||
int start_pos = view.cursor.pos - 1;
|
Stream_Chunk chunk = {0};
|
||||||
|
|
||||||
Stream_Chunk chunk;
|
|
||||||
char chunk_space[(1 << 10)];
|
char chunk_space[(1 << 10)];
|
||||||
|
|
||||||
int result = 0;
|
int32_t result = 0;
|
||||||
int found_result = 0;
|
int32_t found_result = 0;
|
||||||
|
|
||||||
int i = start_pos;
|
int32_t i = view.cursor.pos - 1;
|
||||||
int still_looping = 1;
|
int32_t still_looping = 1;
|
||||||
int nesting_counter = 0;
|
int32_t nesting_counter = 0;
|
||||||
char at_cursor = 0;
|
char at_cursor = 0;
|
||||||
|
|
||||||
if (init_stream_chunk(&chunk, app, &buffer, i, chunk_space, sizeof(chunk_space))){
|
if (init_stream_chunk(&chunk, app, &buffer, i, chunk_space, sizeof(chunk_space))){
|
||||||
|
@ -303,7 +303,7 @@ CUSTOM_COMMAND_SIG(cursor_to_surrounding_scope){
|
||||||
} while(still_looping);
|
} while(still_looping);
|
||||||
}
|
}
|
||||||
|
|
||||||
finished:
|
finished:;
|
||||||
if (found_result){
|
if (found_result){
|
||||||
view_set_cursor(app, &view, seek_pos(result), 0);
|
view_set_cursor(app, &view, seek_pos(result), 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue