fixing up scope commands; fixed the paste next bug
parent
2d63c65d2b
commit
a79f6b41a1
|
@ -81,10 +81,11 @@ CUSTOM_DOC("If the previous command was paste or paste_next, replaces the paste
|
|||
Managed_Scope scope = view_get_managed_scope(app, view);
|
||||
no_mark_snap_to_cursor(app, scope);
|
||||
|
||||
Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
|
||||
*next_rewrite = Rewrite_Paste;
|
||||
|
||||
Rewrite_Type *rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
|
||||
if (*rewrite == Rewrite_Paste){
|
||||
Rewrite_Type *next_rewrite = scope_attachment(app, scope, view_next_rewrite_loc, Rewrite_Type);
|
||||
*next_rewrite = Rewrite_Paste;
|
||||
i32 *paste_index_ptr = scope_attachment(app, scope, view_paste_index_loc, i32);
|
||||
i32 paste_index = (*paste_index_ptr) + 1;
|
||||
*paste_index_ptr = paste_index;
|
||||
|
|
|
@ -4,34 +4,36 @@
|
|||
|
||||
// TOP
|
||||
|
||||
static Find_Scope_Token_Type
|
||||
find_scope_get_token_type(Find_Scope_Flag flags, Token_Base_Kind kind){
|
||||
Find_Scope_Token_Type type = FindScopeTokenType_None;
|
||||
if (flags & FindScope_Scope){
|
||||
switch (kind){
|
||||
case TokenBaseKind_ScopeOpen:
|
||||
{
|
||||
type = FindScopeTokenType_Open;
|
||||
}break;
|
||||
case TokenBaseKind_ScopeClose:
|
||||
{
|
||||
type = FindScopeTokenType_Close;
|
||||
}break;
|
||||
}
|
||||
function Nest_Delimiter_Kind
|
||||
get_nest_delimiter_kind(Token_Base_Kind kind, Find_Scope_Flag flags){
|
||||
Nest_Delimiter_Kind result = NestDelimiterKind_None;
|
||||
switch (kind){
|
||||
case TokenBaseKind_ScopeOpen:
|
||||
{
|
||||
if (HasFlag(flags, FindScope_Scope)){
|
||||
result = NestDelimiterKind_Open;
|
||||
}
|
||||
}break;
|
||||
case TokenBaseKind_ScopeClose:
|
||||
{
|
||||
if (HasFlag(flags, FindScope_Scope)){
|
||||
result = NestDelimiterKind_Close;
|
||||
}
|
||||
}break;
|
||||
case TokenBaseKind_ParentheticalOpen:
|
||||
{
|
||||
if (HasFlag(flags, FindScope_Paren)){
|
||||
result = NestDelimiterKind_Open;
|
||||
}
|
||||
}break;
|
||||
case TokenBaseKind_ParentheticalClose:
|
||||
{
|
||||
if (HasFlag(flags, FindScope_Paren)){
|
||||
result = NestDelimiterKind_Close;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
else if (flags & FindScope_Paren){
|
||||
switch (kind){
|
||||
case TokenBaseKind_ParentheticalOpen:
|
||||
{
|
||||
type = FindScopeTokenType_Open;
|
||||
}break;
|
||||
case TokenBaseKind_ParentheticalClose:
|
||||
{
|
||||
type = FindScopeTokenType_Close;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
return(type);
|
||||
return(result);
|
||||
}
|
||||
|
||||
static b32
|
||||
|
@ -49,9 +51,9 @@ find_scope_top(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 flag
|
|||
i32 nest_level = 0;
|
||||
for (;good_status;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
switch (type){
|
||||
case FindScopeTokenType_Open:
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
switch (delim){
|
||||
case NestDelimiterKind_Open:
|
||||
{
|
||||
if (nest_level == 0){
|
||||
success = true;
|
||||
|
@ -65,7 +67,7 @@ find_scope_top(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 flag
|
|||
--nest_level;
|
||||
}
|
||||
}break;
|
||||
case FindScopeTokenType_Close:
|
||||
case NestDelimiterKind_Close:
|
||||
{
|
||||
++nest_level;
|
||||
}break;
|
||||
|
@ -94,13 +96,13 @@ find_scope_bottom(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 f
|
|||
i32 nest_level = 0;
|
||||
for (;good_status;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
switch (type){
|
||||
case FindScopeTokenType_Open:
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
switch (delim){
|
||||
case NestDelimiterKind_Open:
|
||||
{
|
||||
++nest_level;
|
||||
}break;
|
||||
case FindScopeTokenType_Close:
|
||||
case NestDelimiterKind_Close:
|
||||
{
|
||||
if (nest_level == 0){
|
||||
success = true;
|
||||
|
@ -137,9 +139,9 @@ find_next_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
i32 nest_level = 1;
|
||||
for (;good_status;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
switch (type){
|
||||
case FindScopeTokenType_Open:
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
switch (delim){
|
||||
case NestDelimiterKind_Open:
|
||||
{
|
||||
if (nest_level == 0){
|
||||
success = true;
|
||||
|
@ -153,7 +155,7 @@ find_next_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
++nest_level;
|
||||
}
|
||||
}break;
|
||||
case FindScopeTokenType_Close:
|
||||
case NestDelimiterKind_Close:
|
||||
{
|
||||
--nest_level;
|
||||
if (nest_level == -1){
|
||||
|
@ -169,8 +171,8 @@ find_next_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
b32 good_status = true;
|
||||
for (;good_status;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
if (type == FindScopeTokenType_Open){
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
if (delim == NestDelimiterKind_Open){
|
||||
success = true;
|
||||
position = token->pos;
|
||||
if (flags & FindScope_EndOfToken){
|
||||
|
@ -200,9 +202,9 @@ find_prev_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
i32 nest_level = -1;
|
||||
for (;status_good;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
switch (type){
|
||||
case FindScopeTokenType_Open:
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
switch (delim){
|
||||
case NestDelimiterKind_Open:
|
||||
{
|
||||
if (nest_level == -1){
|
||||
position = start_pos;
|
||||
|
@ -220,7 +222,7 @@ find_prev_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
--nest_level;
|
||||
}
|
||||
}break;
|
||||
case FindScopeTokenType_Close:
|
||||
case NestDelimiterKind_Close:
|
||||
{
|
||||
++nest_level;
|
||||
}break;
|
||||
|
@ -232,8 +234,8 @@ find_prev_scope(Application_Links *app, Buffer_ID buffer, i64 start_pos, u32 fla
|
|||
b32 status_good = token_it_dec(&it);
|
||||
for (;status_good;){
|
||||
Token *token = token_it_read(&it);
|
||||
Find_Scope_Token_Type type = find_scope_get_token_type(flags, token->kind);
|
||||
if (type == FindScopeTokenType_Open){
|
||||
Nest_Delimiter_Kind delim = get_nest_delimiter_kind(token->kind, flags);
|
||||
if (delim == NestDelimiterKind_Open){
|
||||
success = true;
|
||||
position = token->pos;
|
||||
if (HasFlag(flags, FindScope_EndOfToken)){
|
||||
|
|
|
@ -7,6 +7,13 @@
|
|||
#if !defined(FCODER_SCOPE_COMMANDS_H)
|
||||
#define FCODER_SCOPE_COMMANDS_H
|
||||
|
||||
typedef i32 Nest_Delimiter_Kind;
|
||||
enum{
|
||||
NestDelimiterKind_None = 0,
|
||||
NestDelimiterKind_Open = 1,
|
||||
NestDelimiterKind_Close = 2,
|
||||
};
|
||||
|
||||
typedef u32 Find_Scope_Flag;
|
||||
enum{
|
||||
FindScope_Parent = 1,
|
||||
|
@ -16,13 +23,6 @@ enum{
|
|||
FindScope_Paren = 16,
|
||||
};
|
||||
|
||||
typedef i32 Find_Scope_Token_Type;
|
||||
enum{
|
||||
FindScopeTokenType_None = 0,
|
||||
FindScopeTokenType_Open = 1,
|
||||
FindScopeTokenType_Close = 2,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// BOTTOM
|
||||
|
|
|
@ -424,8 +424,8 @@ static Command_Metadata fcoder_metacmd_table[226] = {
|
|||
{ PROC_LINKS(cut, 0), "cut", 3, "Cut the text in the range from the cursor to the mark onto the clipboard.", 73, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 28 },
|
||||
{ PROC_LINKS(paste, 0), "paste", 5, "At the cursor, insert the text at the top of the clipboard.", 59, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 39 },
|
||||
{ PROC_LINKS(paste_next, 0), "paste_next", 10, "If the previous command was paste or paste_next, replaces the paste range with the next text down on the clipboard, otherwise operates as the paste command.", 156, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 73 },
|
||||
{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 114 },
|
||||
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 121 },
|
||||
{ PROC_LINKS(paste_and_indent, 0), "paste_and_indent", 16, "Paste from the top of clipboard and run auto-indent on the newly pasted text.", 77, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 115 },
|
||||
{ PROC_LINKS(paste_next_and_indent, 0), "paste_next_and_indent", 21, "Paste the next item on the clipboard and run auto-indent on the newly pasted text.", 82, "w:\\4ed\\code\\custom\\4coder_clipboard.cpp", 39, 122 },
|
||||
{ PROC_LINKS(execute_previous_cli, 0), "execute_previous_cli", 20, "If the command execute_any_cli has already been used, this will execute a CLI reusing the most recent buffer name and command.", 126, "w:\\4ed\\code\\custom\\4coder_system_command.cpp", 44, 7 },
|
||||
{ PROC_LINKS(execute_any_cli, 0), "execute_any_cli", 15, "Queries for an output buffer name and system command, runs the system command as a CLI and prints the output to the specified buffer.", 133, "w:\\4ed\\code\\custom\\4coder_system_command.cpp", 44, 22 },
|
||||
{ PROC_LINKS(build_search, 0), "build_search", 12, "Looks for a build.bat, build.sh, or makefile in the current and parent directories. Runs the first that it finds and prints the output to *compilation*.", 153, "w:\\4ed\\code\\custom\\4coder_build_commands.cpp", 44, 128 },
|
||||
|
@ -447,11 +447,11 @@ static Command_Metadata fcoder_metacmd_table[226] = {
|
|||
{ PROC_LINKS(list_all_functions_current_buffer_lister, 0), "list_all_functions_current_buffer_lister", 40, "Creates a lister of locations that look like function definitions and declarations in the buffer.", 97, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 277 },
|
||||
{ PROC_LINKS(list_all_functions_all_buffers, 0), "list_all_functions_all_buffers", 30, "Creates a jump list of lines from all buffers that appear to define or declare functions.", 89, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 289 },
|
||||
{ PROC_LINKS(list_all_functions_all_buffers_lister, 0), "list_all_functions_all_buffers_lister", 37, "Creates a lister of locations that look like function definitions and declarations all buffers.", 95, "w:\\4ed\\code\\custom\\4coder_function_list.cpp", 43, 295 },
|
||||
{ PROC_LINKS(select_surrounding_scope, 0), "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 319 },
|
||||
{ PROC_LINKS(select_next_scope_absolute, 0), "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 334 },
|
||||
{ PROC_LINKS(select_prev_scope_absolute, 0), "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 353 },
|
||||
{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 427 },
|
||||
{ PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 433 },
|
||||
{ PROC_LINKS(select_surrounding_scope, 0), "select_surrounding_scope", 24, "Finds the scope enclosed by '{' '}' surrounding the cursor and puts the cursor and mark on the '{' and '}'.", 107, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 321 },
|
||||
{ PROC_LINKS(select_next_scope_absolute, 0), "select_next_scope_absolute", 26, "Finds the first scope started by '{' after the cursor and puts the cursor and mark on the '{' and '}'.", 102, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 336 },
|
||||
{ PROC_LINKS(select_prev_scope_absolute, 0), "select_prev_scope_absolute", 26, "Finds the first scope started by '{' before the cursor and puts the cursor and mark on the '{' and '}'.", 103, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 355 },
|
||||
{ PROC_LINKS(place_in_scope, 0), "place_in_scope", 14, "Wraps the code contained in the range between cursor and mark with a new curly brace scope.", 91, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 429 },
|
||||
{ PROC_LINKS(delete_current_scope, 0), "delete_current_scope", 20, "Deletes the braces surrounding the currently selected scope. Leaves the contents within the scope.", 99, "w:\\4ed\\code\\custom\\4coder_scope_commands.cpp", 44, 435 },
|
||||
{ PROC_LINKS(open_long_braces, 0), "open_long_braces", 16, "At the cursor, insert a '{' and '}' separated by a blank line.", 62, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 46 },
|
||||
{ PROC_LINKS(open_long_braces_semicolon, 0), "open_long_braces_semicolon", 26, "At the cursor, insert a '{' and '};' separated by a blank line.", 63, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 54 },
|
||||
{ PROC_LINKS(open_long_braces_break, 0), "open_long_braces_break", 22, "At the cursor, insert a '{' and '}break;' separated by a blank line.", 68, "w:\\4ed\\code\\custom\\4coder_combined_write_commands.cpp", 53, 62 },
|
||||
|
|
Loading…
Reference in New Issue