mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-10-11 18:30:22 +00:00
checkpoint on text patches
This commit is contained in:
+4
-172
@@ -2186,7 +2186,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
TXT_ScopeNode *cursor_scope_node = &txt_scope_node_nil;
|
||||
if(params->text_info != 0)
|
||||
{
|
||||
cursor_scope_node = txt_scope_node_from_info_pt(params->text_info, rd_regs()->cursor);
|
||||
cursor_scope_node = txt_scope_node_from_info_pt(params->text_info, params->patches, rd_regs()->cursor);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -2214,7 +2214,7 @@ rd_code_slice(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *prefe
|
||||
scope_line_color.w = scope_line_color_t*0.5f;
|
||||
Rng1U64 token_idx_range = scope_n->token_idx_range;
|
||||
Rng1U64 off_range = r1u64(params->text_info->tokens.v[token_idx_range.min].range.min, params->text_info->tokens.v[token_idx_range.max].range.min);
|
||||
TxtRng txt_range = txt_rng(txt_pt_from_info_off__linear_scan(params->text_info, off_range.min), txt_pt_from_info_off__linear_scan(params->text_info, off_range.max));
|
||||
TxtRng txt_range = txt_rng(txt_pt_from_off__linear_scan(params->text_info, params->patches, off_range.min), txt_pt_from_off__linear_scan(params->text_info, params->patches, off_range.max));
|
||||
|
||||
//- rjf: single-line scopes (underline)
|
||||
if(txt_range.min.line == txt_range.max.line && contains_1s64(params->line_num_range, txt_range.min.line))
|
||||
@@ -2999,179 +2999,11 @@ rd_code_slicef(RD_CodeSliceParams *params, TxtPt *cursor, TxtPt *mark, S64 *pref
|
||||
}
|
||||
|
||||
internal B32
|
||||
rd_do_txt_controls(TXT_TextInfo *info, String8 data, U64 line_count_per_page, TxtPt *cursor, TxtPt *mark, S64 *preferred_column)
|
||||
rd_do_txt_controls(TXT_TextInfo *info, String8 data, TXT_PatchList *patches, U64 line_count_per_page, TxtPt *cursor, TxtPt *mark, S64 *preferred_column)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
B32 change = 0;
|
||||
for(UI_Event *evt = 0; ui_next_event(&evt);)
|
||||
{
|
||||
if(evt->kind != UI_EventKind_Navigate && evt->kind != UI_EventKind_Edit)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
B32 taken = 0;
|
||||
String8 line = txt_string_from_info_data_line_num(info, data, cursor->line);
|
||||
UI_TxtOp single_line_op = ui_single_line_txt_op_from_event(scratch.arena, evt, line, *cursor, *mark);
|
||||
|
||||
//- rjf: invalid single-line op or endpoint units => try multiline
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Whole || single_line_op.flags & UI_TxtOpFlag_Invalid)
|
||||
{
|
||||
U64 line_count = info->lines_count;
|
||||
String8 prev_line = txt_string_from_info_data_line_num(info, data, cursor->line-1);
|
||||
String8 next_line = txt_string_from_info_data_line_num(info, data, cursor->line+1);
|
||||
Vec2S32 delta = evt->delta_2s32;
|
||||
|
||||
//- rjf: wrap lines right
|
||||
if(evt->delta_unit != UI_EventDeltaUnit_Whole && delta.x > 0 && cursor->column == line.size+1 && cursor->line+1 <= line_count)
|
||||
{
|
||||
cursor->line += 1;
|
||||
cursor->column = 1;
|
||||
*preferred_column = 1;
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: wrap lines left
|
||||
if(evt->delta_unit != UI_EventDeltaUnit_Whole && delta.x < 0 && cursor->column == 1 && cursor->line-1 >= 1)
|
||||
{
|
||||
cursor->line -= 1;
|
||||
cursor->column = prev_line.size+1;
|
||||
*preferred_column = prev_line.size+1;
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement down (plain)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Char && delta.y > 0 && cursor->line+1 <= line_count)
|
||||
{
|
||||
cursor->line += 1;
|
||||
cursor->column = Min(*preferred_column, next_line.size+1);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement up (plain)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Char && delta.y < 0 && cursor->line-1 >= 1)
|
||||
{
|
||||
cursor->line -= 1;
|
||||
cursor->column = Min(*preferred_column, prev_line.size+1);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement down (chunk)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Word && delta.y > 0 && cursor->line+1 <= line_count)
|
||||
{
|
||||
for(S64 line_num = cursor->line+1; line_num <= line_count; line_num += 1)
|
||||
{
|
||||
String8 line = txt_string_from_info_data_line_num(info, data, line_num);
|
||||
U64 line_size = line.size;
|
||||
if(line_size == 0)
|
||||
{
|
||||
cursor->line = line_num;
|
||||
cursor->column = 1;
|
||||
break;
|
||||
}
|
||||
else if(line_num == line_count)
|
||||
{
|
||||
cursor->line = line_num;
|
||||
cursor->column = line_size+1;
|
||||
}
|
||||
}
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement up (chunk)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Word && delta.y < 0 && cursor->line-1 >= 1)
|
||||
{
|
||||
for(S64 line_num = cursor->line-1; line_num > 0; line_num -= 1)
|
||||
{
|
||||
String8 line = txt_string_from_info_data_line_num(info, data, line_num);
|
||||
U64 line_size = line.size;
|
||||
if(line_size == 0)
|
||||
{
|
||||
cursor->line = line_num;
|
||||
cursor->column = 1;
|
||||
break;
|
||||
}
|
||||
else if(line_num == 1)
|
||||
{
|
||||
cursor->line = line_num;
|
||||
cursor->column = 1;
|
||||
}
|
||||
}
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement down (page)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Page && delta.y > 0)
|
||||
{
|
||||
cursor->line += line_count_per_page;
|
||||
cursor->column = 1;
|
||||
cursor->line = Clamp(1, cursor->line, line_count);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement up (page)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Page && delta.y < 0)
|
||||
{
|
||||
cursor->line -= line_count_per_page;
|
||||
cursor->column = 1;
|
||||
cursor->line = Clamp(1, cursor->line, line_count);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement to endpoint (+)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Whole && (delta.y > 0 || delta.x > 0))
|
||||
{
|
||||
*cursor = txt_pt(line_count, info->lines_count ? dim_1u64(info->lines_ranges[info->lines_count-1])+1 : 1);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: movement to endpoint (-)
|
||||
if(evt->delta_unit == UI_EventDeltaUnit_Whole && (delta.y < 0 || delta.x < 0))
|
||||
{
|
||||
*cursor = txt_pt(1, 1);
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: stick mark to cursor, when we don't want to keep it in the same spot
|
||||
if(!(evt->flags & UI_EventFlag_KeepMark))
|
||||
{
|
||||
*mark = *cursor;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: valid single-line op => do single-line op
|
||||
else
|
||||
{
|
||||
*cursor = single_line_op.cursor;
|
||||
*mark = single_line_op.mark;
|
||||
*preferred_column = cursor->column;
|
||||
change = 1;
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: copy
|
||||
if(evt->flags & UI_EventFlag_Copy)
|
||||
{
|
||||
String8 text = txt_string_from_info_data_txt_rng(info, data, txt_rng(*cursor, *mark));
|
||||
wm_set_clipboard_text(text);
|
||||
taken = 1;
|
||||
}
|
||||
|
||||
//- rjf: consume
|
||||
if(taken)
|
||||
{
|
||||
ui_eat_event(evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
scratch_end(scratch);
|
||||
return change;
|
||||
|
||||
Reference in New Issue
Block a user