window.h
Go to the documentation of this file.
1 #ifndef NVIM_WINDOW_H
2 #define NVIM_WINDOW_H
3 
4 #include <stdbool.h>
5 
6 #include "nvim/buffer_defs.h"
7 #include "nvim/mark.h"
8 #include "nvim/os/os.h"
9 
10 // Values for file_name_in_line()
11 #define FNAME_MESS 1 // give error message
12 #define FNAME_EXP 2 // expand to path
13 #define FNAME_HYP 4 // check for hypertext link
14 #define FNAME_INCL 8 // apply 'includeexpr'
15 #define FNAME_REL 16 // ".." and "./" are relative to the (current)
16  // file instead of the current directory
17 #define FNAME_UNESC 32 // remove backslashes used for escaping
18 
19 // arguments for win_split()
20 #define WSP_ROOM 1 // require enough room
21 #define WSP_VERT 2 // split vertically
22 #define WSP_TOP 4 // window at top-left of shell
23 #define WSP_BOT 8 // window at bottom-right of shell
24 #define WSP_HELP 16 // creating the help window
25 #define WSP_BELOW 32 // put new window below/right
26 #define WSP_ABOVE 64 // put new window above/left
27 #define WSP_NEWLOC 128 // don't copy location list
28 
29 // Minimum screen size
30 #define MIN_COLUMNS 12 // minimal columns for screen
31 #define MIN_LINES 2 // minimal lines for screen
32 
34 typedef struct {
37  bool sw_same_win;
39 } switchwin_T;
40 
43 #define WIN_EXECUTE(wp, tp, block) \
44  do { \
45  win_T *const wp_ = (wp); \
46  const pos_T curpos_ = wp_->w_cursor; \
47  char_u cwd_[MAXPATHL]; \
48  char_u autocwd_[MAXPATHL]; \
49  bool apply_acd_ = false; \
50  int cwd_status_ = FAIL; \
51  /* Getting and setting directory can be slow on some systems, only do */ \
52  /* this when the current or target window/tab have a local directory or */ \
53  /* 'acd' is set. */ \
54  if (curwin != wp \
55  && (curwin->w_localdir != NULL || wp->w_localdir != NULL \
56  || (curtab != tp && (curtab->tp_localdir != NULL || tp->tp_localdir != NULL)) \
57  || p_acd)) { \
58  cwd_status_ = os_dirname(cwd_, MAXPATHL); \
59  } \
60  /* If 'acd' is set, check we are using that directory. If yes, then */ \
61  /* apply 'acd' afterwards, otherwise restore the current directory. */ \
62  if (cwd_status_ == OK && p_acd) { \
63  do_autochdir(); \
64  apply_acd_ = os_dirname(autocwd_, MAXPATHL) == OK && STRCMP(cwd_, autocwd_) == 0; \
65  } \
66  switchwin_T switchwin_; \
67  if (switch_win_noblock(&switchwin_, wp_, (tp), true) == OK) { \
68  check_cursor(); \
69  block; \
70  } \
71  restore_win_noblock(&switchwin_, true); \
72  if (apply_acd_) { \
73  do_autochdir(); \
74  } else if (cwd_status_ == OK) { \
75  os_chdir((char *)cwd_); \
76  } \
77  /* Update the status line if the cursor moved. */ \
78  if (win_valid(wp_) && !equalpos(curpos_, wp_->w_cursor)) { \
79  wp_->w_redr_status = true; \
80  } \
81  /* In case the command moved the cursor or changed the Visual area, */ \
82  /* check it is valid. */ \
83  check_cursor(); \
84  if (VIsual_active) { \
85  check_pos(curbuf, &VIsual); \
86  } \
87  } while (false)
88 
89 #ifdef INCLUDE_GENERATED_DECLARATIONS
90 # include "window.h.generated.h"
91 #endif
92 #endif // NVIM_WINDOW_H
os.h
window_S
Definition: buffer_defs.h:1171
tabpage_S
Definition: buffer_defs.h:942
switchwin_T
Structure used by switch_win() to pass values to restore_win()
Definition: window.h:34
switchwin_T::sw_same_win
bool sw_same_win
VIsual_active was not reset.
Definition: window.h:37
switchwin_T::sw_curwin
win_T * sw_curwin
Definition: window.h:35
switchwin_T::sw_visual_active
bool sw_visual_active
Definition: window.h:38
buffer_defs.h
switchwin_T::sw_curtab
tabpage_T * sw_curtab
Definition: window.h:36
mark.h