-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuffers.c
57 lines (48 loc) · 1.04 KB
/
buffers.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include "pos.h"
#include "region.h"
#include "list.h"
#include "buffer.h"
#include "buffers.h"
#include "window.h"
#include "windows.h"
#include "tab.h"
#include "tabs.h"
buffer_t *buffers_find(const char *fname)
{
if(!windows_cur()) /* called on startup */
return NULL;
for(tab *tab = tabs_first(); tab; tab = tab->next){
window *win;
ITER_WINDOWS_FROM(win, tab->win){
buffer_t *buf = win->buf;
const char *thisfname = buffer_fname(buf);
if(thisfname && !strcmp(thisfname, fname))
return buf;
}
}
return NULL;
}
bool buffers_modified_single(const buffer_t *b)
{
return b->modified && buffer_opencount(b) == 1;
}
window *buffers_modified_excluding(buffer_t *excluding, tab **const ptab)
{
if(ptab)
*ptab = NULL;
for(tab *tab = tabs_first(); tab; tab = tab->next){
window *win;
ITER_WINDOWS_FROM(win, tab->win){
buffer_t *buf = win->buf;
if(buf != excluding && buf->modified){
if(ptab)
*ptab = tab;
return win;
}
}
}
return NULL;
}