ref: bc56c51c61e71212eaa99f39aae9c481a1d3311b
parent: 624a27200c2c94d09f05b372f0912cc7b9d98a7f
author: Nicola Pisanti <nicola@npisanti.com>
date: Sat Jun 15 08:02:18 EDT 2019
reverts tui methods to int for avoiding overflow, fixes #46
--- a/tui_main.c
+++ b/tui_main.c
@@ -1286,7 +1286,7 @@
a->is_draw_dirty = true;
}
-Usz guarded_selection_axis_resize(Usz x, Isz delta) {
+Usz guarded_selection_axis_resize(Usz x, int delta) {
if (delta < 0) {
if (delta > INT_MIN && (Usz)(-delta) < x) {
x -= (Usz)(-delta);
@@ -1297,7 +1297,7 @@
return x;
}
-void ged_modify_selection_size(Ged* a, Isz delta_y, Isz delta_x) {
+void ged_modify_selection_size(Ged* a, int delta_y, int delta_x) {
Usz cur_h = a->ged_cursor.h;
Usz cur_w = a->ged_cursor.w;
Usz new_h = guarded_selection_axis_resize(cur_h, delta_y);
@@ -1316,7 +1316,7 @@
Ged_dir_right,
} Ged_dir;
-void ged_dir_input(Ged* a, Ged_dir dir, Isz step_length) {
+void ged_dir_input(Ged* a, Ged_dir dir, int step_length) {
switch (a->input_mode) {
case Ged_input_mode_normal:
case Ged_input_mode_append:
@@ -2476,16 +2476,16 @@
ged_modify_selection_size(&ged_state, 0, 1);
break;
case 567: // shift-control-up
- ged_modify_selection_size(&ged_state, -(Isz)ged_state.ruler_spacing_y, 0);
+ ged_modify_selection_size(&ged_state, -(int)ged_state.ruler_spacing_y, 0);
break;
case 526: // shift-control-down
- ged_modify_selection_size(&ged_state, (Isz)ged_state.ruler_spacing_y, 0);
+ ged_modify_selection_size(&ged_state, (int)ged_state.ruler_spacing_y, 0);
break;
case 546: // shift-control-left
- ged_modify_selection_size(&ged_state, 0, -(Isz)ged_state.ruler_spacing_x);
+ ged_modify_selection_size(&ged_state, 0, -(int)ged_state.ruler_spacing_x);
break;
case 561: // shift-control-right
- ged_modify_selection_size(&ged_state, 0, (Isz)ged_state.ruler_spacing_x);
+ ged_modify_selection_size(&ged_state, 0, (int)ged_state.ruler_spacing_x);
break;
case 330: // delete?
@@ -2494,16 +2494,16 @@
// Jump on control-arrow
case 566: //control-up
- ged_dir_input(&ged_state, Ged_dir_up, (Isz)ged_state.ruler_spacing_y);
+ ged_dir_input(&ged_state, Ged_dir_up, (int)ged_state.ruler_spacing_y);
break;
case 525: //control-down
- ged_dir_input(&ged_state, Ged_dir_down, (Isz)ged_state.ruler_spacing_y);
+ ged_dir_input(&ged_state, Ged_dir_down, (int)ged_state.ruler_spacing_y);
break;
case 545: //control-left
- ged_dir_input(&ged_state, Ged_dir_left, (Isz)ged_state.ruler_spacing_x);
+ ged_dir_input(&ged_state, Ged_dir_left, (int)ged_state.ruler_spacing_x);
break;
case 560: //control-right
- ged_dir_input(&ged_state, Ged_dir_right, (Isz)ged_state.ruler_spacing_x);
+ ged_dir_input(&ged_state, Ged_dir_right, (int)ged_state.ruler_spacing_x);
break;
case CTRL_PLUS('d'):