-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathSTATUS.C
116 lines (101 loc) · 2.38 KB
/
STATUS.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* Copyright (c) 1990,1991,1992 Chris and John Downey */
#ifndef lint
static char *sccsid = "@(#)status.c 2.1 (Chris & John Downey) 7/29/92";
#endif
/***
* program name:
xvi
* function:
PD version of UNIX "vi" editor, with extensions.
* module name:
status.c
* module function:
Routines to print status line messages.
* history:
STEVIE - ST Editor for VI Enthusiasts, Version 3.10
Originally by Tim Thompson (twitch!tjt)
Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
Heavily modified by Chris & John Downey
***/
#include "xvi.h"
/*
* Set up the "slinetype" field in the given buffer structure,
* according to the number of columns available.
*/
void
init_sline(win)
Xviwin *win;
{
flexclear(&win->w_statusline);
}
/*VARARGS2*/
/*PRINTFLIKE*/
void
show_message
#ifdef __STDC__
(Xviwin *window, char *format, ...)
#else /* not __STDC__ */
(window, format, va_alist)
Xviwin *window;
char *format;
va_dcl
#endif /* __STDC__ */
{
va_list argp;
VA_START(argp, format);
(void) flexclear(&window->w_statusline);
(void) vformat(&window->w_statusline, format, argp);
va_end(argp);
update_sline(window);
}
/*VARARGS2*/
/*PRINTFLIKE*/
void
show_error
#ifdef __STDC__
(Xviwin *window, char *format, ...)
#else /* not __STDC__ */
(window, format, va_alist)
Xviwin *window;
char *format;
va_dcl
#endif /* __STDC__ */
{
va_list argp;
beep(window);
VA_START(argp, format);
(void) flexclear(&window->w_statusline);
(void) vformat(&window->w_statusline, format, argp);
va_end(argp);
update_sline(window);
}
void
show_file_info(window)
Xviwin *window;
{
if (echo & e_SHOWINFO) {
Buffer *buffer;
Flexbuf *slp;
long position, total;
long percentage;
buffer = window->w_buffer;
position = lineno(buffer, window->w_cursor->p_line);
total = lineno(buffer, buffer->b_lastline->l_prev);
percentage = (total > 0) ? (position * 100) / total : 0;
slp = &window->w_statusline;
flexclear(slp);
if (buffer->b_filename == NULL) {
(void) lformat(slp, "No File ");
} else {
(void) lformat(slp, "\"%s\" ", buffer->b_filename);
}
(void) lformat(slp, "%s%s%sline %ld of %ld (%ld%%)",
is_readonly(buffer) ? "[Read only] " : "",
not_editable(buffer) ? "[Not editable] " : "",
is_modified(buffer) ? "[Modified] " : "",
position,
total,
percentage);
}
update_sline(window);
}