| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #ifndef WINDOW_H | ||
| 2 | #define WINDOW_H | ||
| 3 | |||
| 4 | #include <stdbool.h> | ||
| 5 | #include <stddef.h> | ||
| 6 | #include "buffer.h" | ||
| 7 | #include "frame.h" | ||
| 8 | #include "util/debug.h" | ||
| 9 | #include "util/macros.h" | ||
| 10 | #include "util/ptr-array.h" | ||
| 11 | #include "view.h" | ||
| 12 | |||
| 13 | enum { | ||
| 14 | // Minimum width of line numbers bar (including padding) | ||
| 15 | LINE_NUMBERS_MIN_WIDTH = 5 | ||
| 16 | }; | ||
| 17 | |||
| 18 | // A sub-division of the screen, similar to a window in a tiling window | ||
| 19 | // manager. There can be multiple Views associated with each Window, but | ||
| 20 | // only one is visible at a time. Each tab displayed in the tab bar | ||
| 21 | // corresponds to a View and the editable text area corresponds to the | ||
| 22 | // Buffer of the *current* View (Window::view::buffer). | ||
| 23 | typedef struct Window { | ||
| 24 | struct EditorState *editor; // Editor session containing this Window | ||
| 25 | PointerArray views; // All Views contained by this Window | ||
| 26 | Frame *frame; // Parent Frame containing this Window | ||
| 27 | View *view; // Current View | ||
| 28 | View *prev_view; // Previous view, if set | ||
| 29 | int x, y; // Coordinates for top left of window | ||
| 30 | int w, h; // Width and height of window (including tabbar and statusline) | ||
| 31 | int edit_x, edit_y; // Top left of editable area | ||
| 32 | int edit_w, edit_h; // Width and height of editable area | ||
| 33 | size_t first_tab_idx; | ||
| 34 | bool update_tabbar; | ||
| 35 | unsigned int lineno_width; // Width of line numbers bar (including padding) | ||
| 36 | long lineno_first; // First visible line number, in previous screen update | ||
| 37 | long lineno_last; // Last visible line number, in previous screen update | ||
| 38 | } Window; | ||
| 39 | |||
| 40 | 9 | static inline View *window_get_first_view(const Window *window) | |
| 41 | { | ||
| 42 | 9 | BUG_ON(window->views.count == 0); | |
| 43 | 9 | return window->views.ptrs[0]; | |
| 44 | } | ||
| 45 | |||
| 46 | struct EditorState; | ||
| 47 | |||
| 48 | Window *new_window(struct EditorState *e) NONNULL_ARGS_AND_RETURN; | ||
| 49 | View *window_add_buffer(Window *window, Buffer *buffer) NONNULL_ARGS_AND_RETURN; | ||
| 50 | View *window_open_empty_buffer(Window *window) NONNULL_ARGS_AND_RETURN; | ||
| 51 | View *window_open_buffer(Window *window, const char *filename, bool must_exist, const char *encoding) NONNULL_ARG(1, 2); | ||
| 52 | View *window_find_or_create_view(Window *window, Buffer *buffer) NONNULL_ARGS_AND_RETURN; | ||
| 53 | View *window_find_view(Window *window, Buffer *buffer) NONNULL_ARGS; | ||
| 54 | size_t window_count_uncloseable_views(const Window *window, View **first_uncloseable) NONNULL_ARGS WRITEONLY(2); | ||
| 55 | void window_remove_view_at_index(Window *window, size_t view_idx) NONNULL_ARGS; | ||
| 56 | void window_free(Window *window) NONNULL_ARGS; | ||
| 57 | void window_close(Window *window) NONNULL_ARGS; | ||
| 58 | void window_close_current_view(Window *window) NONNULL_ARGS; | ||
| 59 | View *window_open_new_file(Window *window) NONNULL_ARGS; | ||
| 60 | View *window_open_file(Window *window, const char *filename, const char *encoding) NONNULL_ARG(1, 2); | ||
| 61 | View *window_open_files(Window *window, char **filenames, const char *encoding) NONNULL_ARG(1, 2); | ||
| 62 | void window_calculate_line_numbers(Window *window) NONNULL_ARGS; | ||
| 63 | void window_set_coordinates(Window *window, int x, int y) NONNULL_ARGS; | ||
| 64 | void window_set_size(Window *window, int w, int h) NONNULL_ARGS; | ||
| 65 | unsigned int window_get_scroll_margin(const Window *window) NONNULL_ARGS; | ||
| 66 | Window *window_prev(Window *window) NONNULL_ARGS_AND_RETURN; | ||
| 67 | Window *window_next(Window *window) NONNULL_ARGS_AND_RETURN; | ||
| 68 | void frame_for_each_window(const Frame *frame, void (*func)(Window*, void*), void *data) NONNULL_ARG(1, 2); | ||
| 69 | void buffer_mark_tabbars_changed(Buffer *buffer) NONNULL_ARGS; | ||
| 70 | void set_view(View *view) NONNULL_ARGS; | ||
| 71 | |||
| 72 | #endif | ||
| 73 |