diff options
-rw-r--r-- | buffer.c | 4 | ||||
-rw-r--r-- | gl.c | 4 | ||||
-rw-r--r-- | main.c | 7 | ||||
-rw-r--r-- | node.c | 4 | ||||
-rw-r--r-- | ted.h | 1 |
5 files changed, 16 insertions, 4 deletions
@@ -844,6 +844,9 @@ void buffer_scroll_to_pos(TextBuffer *buffer, BufferPos pos) { double display_cols = buffer_display_cols(buffer); double scroll_x = buffer->scroll_x, scroll_y = buffer->scroll_y; double scrolloff = settings->scrolloff; + + // for very small buffers, the scrolloff might need to be reduced. + scrolloff = mind(scrolloff, display_lines * 0.5); // scroll left if pos is off screen in that direction double max_scroll_x = col - scrolloff; @@ -2073,6 +2076,7 @@ void buffer_render(TextBuffer *buffer, Rect r) { // set x1,y1,x2,y2 to an size 0 rectangle buffer->x1 = buffer->x2 = r.pos.x; buffer->y1 = buffer->y2 = r.pos.y; + return; } float x1, y1, x2, y2; @@ -212,6 +212,10 @@ static void gl_geometry_rect(Rect r, u32 color_rgba) { static void gl_geometry_rect_border(Rect r, float border_thickness, u32 color) { float border_radius = border_thickness * 0.5f; float x1 = r.pos.x, y1 = r.pos.y, x2 = x1 + r.size.x, y2 = y1 + r.size.y; + + // make sure rectangle isn't too small + x2 = maxf(x2, x1 + 2 * border_radius); + y2 = maxf(y2, y1 + 2 * border_radius); gl_geometry_rect(rect4(x1+border_radius, y1-border_radius, x2+border_radius, y1+border_radius), color); gl_geometry_rect(rect4(x1-border_radius, y2-border_radius, x2-border_radius, y2+border_radius), color); @@ -1,5 +1,4 @@ // @TODO: -// - resize split (i.e. change split_pos) // - move tabs between nodes // - Windows installation @@ -525,7 +524,11 @@ int main(int argc, char **argv) { } break; } } - + { + int mx = 0, my = 0; + ted->mouse_state = SDL_GetMouseState(&mx, &my); + ted->mouse_pos = V2((float)mx, (float)my); + } // default to arrow cursor ted->cursor = ted->cursor_arrow; if (!(ted->mouse_state & SDL_BUTTON_LMASK)) { @@ -283,7 +283,7 @@ static void node_frame(Ted *ted, Node *node, Rect r) { float rect_coord1 = (node->split_vertical ? rect_y1 : rect_x1)(r); float rect_coord2 = (node->split_vertical ? rect_y2 : rect_x2)(r); // make sure the split doesn't make one of the sides too small - float min_split = 10.0f / (node->split_vertical ? r.size.y : r.size.x); + float min_split = 50.0f / (node->split_vertical ? r.size.y : r.size.x); node->split_pos = clampf(normf(mouse_coord, rect_coord1, rect_coord2), min_split, 1-min_split); } } @@ -316,7 +316,7 @@ static void node_frame(Ted *ted, Node *node, Rect r) { } static void node_split(Ted *ted, Node *node, bool vertical) { - if (node_depth(ted, (u16)(node - ted->nodes)) >= 5) return; // prevent splitting too deep + if (node_depth(ted, (u16)(node - ted->nodes)) >= 4) return; // prevent splitting too deep if (arr_len(node->tabs) > 1) { // need at least 2 tabs to split i32 left_idx = ted_new_node(ted); @@ -203,6 +203,7 @@ typedef struct { // a node is a collection of tabs OR a split of two nodes typedef struct Node { u16 *tabs; // dynamic array of indices into ted->buffers, or NULL if this is a split + v2 size; // size of node, as a percentage of the window dimensions float split_pos; // number from 0 to 1 indicating where the split is. u16 active_tab; // index of active tab in tabs. bool split_vertical; // is the split vertical? if false, this split looks like a|b |