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 |
|
|
struct { |
36 |
|
|
int width; |
37 |
|
|
long first; |
38 |
|
|
long last; |
39 |
|
|
} line_numbers; |
40 |
|
|
} Window; |
41 |
|
|
|
42 |
|
6 |
static inline View *window_get_first_view(const Window *window) |
43 |
|
|
{ |
44 |
|
6 |
BUG_ON(window->views.count == 0); |
45 |
|
6 |
return window->views.ptrs[0]; |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
struct EditorState; |
49 |
|
|
|
50 |
|
|
Window *new_window(struct EditorState *e) NONNULL_ARGS_AND_RETURN; |
51 |
|
|
View *window_add_buffer(Window *window, Buffer *buffer) NONNULL_ARGS_AND_RETURN; |
52 |
|
|
View *window_open_empty_buffer(Window *window) NONNULL_ARGS_AND_RETURN; |
53 |
|
|
View *window_open_buffer(Window *window, const char *filename, bool must_exist, const char *encoding) NONNULL_ARG(1, 2); |
54 |
|
|
View *window_find_or_create_view(Window *window, Buffer *buffer) NONNULL_ARGS_AND_RETURN; |
55 |
|
|
View *window_find_view(Window *window, Buffer *buffer) NONNULL_ARGS; |
56 |
|
|
View *window_find_unclosable_view(Window *window) NONNULL_ARGS; |
57 |
|
|
void window_free(Window *window) NONNULL_ARGS; |
58 |
|
|
void window_close(Window *window) NONNULL_ARGS; |
59 |
|
|
void window_close_current_view(Window *window) NONNULL_ARGS; |
60 |
|
|
View *window_open_new_file(Window *window) NONNULL_ARGS; |
61 |
|
|
View *window_open_file(Window *window, const char *filename, const char *encoding) NONNULL_ARG(1, 2); |
62 |
|
|
View *window_open_files(Window *window, char **filenames, const char *encoding) NONNULL_ARG(1, 2); |
63 |
|
|
void window_calculate_line_numbers(Window *window) NONNULL_ARGS; |
64 |
|
|
void window_set_coordinates(Window *window, int x, int y) NONNULL_ARGS; |
65 |
|
|
void window_set_size(Window *window, int w, int h) NONNULL_ARGS; |
66 |
|
|
unsigned int window_get_scroll_margin(const Window *window) NONNULL_ARGS; |
67 |
|
|
Window *window_prev(Window *window) NONNULL_ARGS_AND_RETURN; |
68 |
|
|
Window *window_next(Window *window) NONNULL_ARGS_AND_RETURN; |
69 |
|
|
void frame_for_each_window(const Frame *frame, void (*func)(Window*, void*), void *data) NONNULL_ARG(1, 2); |
70 |
|
|
void buffer_mark_tabbars_changed(Buffer *buffer) NONNULL_ARGS; |
71 |
|
|
void set_view(View *view) NONNULL_ARGS; |
72 |
|
|
size_t remove_view(View *view) NONNULL_ARGS; |
73 |
|
|
|
74 |
|
|
#endif |
75 |
|
|
|