2 * Copyright (C) 2008 Diego Hernan Borghetti.
18 void e_status_putc(E_Eco
*ec
, int c
)
20 if (ec
->view
->stcol
> ec
->view
->rcol
)
23 e_term_move(ec
->view
->strow
, ec
->view
->stcol
);
25 e_term_fgcol(ec
->tr
, E_TR_RED
);
26 e_term_bgcol(ec
->tr
, E_TR_BLACK
);
29 e_term_fgcol(ec
->tr
, ec
->view
->stfg
);
30 e_term_bgcol(ec
->tr
, ec
->view
->stbg
);
37 void e_status_putc_string(E_Eco
*ec
, char *s
)
41 for (i
= 0; i
< strlen (s
); i
++)
42 e_status_putc(ec
, s
[i
]);
45 void e_status_putc_msg(E_Eco
*ec
)
52 for (i
= 0; i
< ec
->view
->stused
; i
++)
53 e_status_putc(ec
, ec
->view
->stbuf
[i
]);
56 void e_status_set_msg(E_Eco
*ec
, char *fmt
, ...)
61 vsnprintf(ec
->view
->stbuf
, 79, fmt
, ap
);
62 ec
->view
->stused
= strlen(ec
->view
->stbuf
);
70 char *e_status_get_msg(E_Eco
*ec
, char *prompt
)
74 ec
->view
->stcol
= ec
->view
->col
;
75 ec
->view
->strow
= ec
->view
->rrow
;
77 /* need clean the status line. */
78 /* this work in all terms ? */
79 e_term_move(ec
->view
->strow
, ec
->view
->stcol
);
85 e_status_putc_string(ec
, prompt
);
87 e_status_putc(ec
, ':');
92 ec
->view
->stbuf
[i
]= '\0';
97 else if (c
== '\b' && i
) {
99 e_status_putc(ec
, ' ');
101 e_term_move(ec
->view
->strow
, ec
->view
->stcol
);
102 ec
->view
->stbuf
[i
]= '\0';
106 else if (c
> 0x00 && c
< 0x20) {
111 else if ((c
>= 0x20) && (c
< 0x7f)) {
112 ec
->view
->stbuf
[i
]= c
;
114 e_status_putc(ec
, c
);
120 return(ec
->view
->stbuf
);
124 void e_status_draw(E_Eco
*ec
)
131 * The status draw is always call after e_update, so
132 * the physical and virtual cursor are already sync,
133 * we need save the current position to restore
139 ec
->view
->stcol
= ec
->view
->col
;
140 ec
->view
->strow
= ec
->view
->rrow
;
142 if (ec
->view
->b
->flag
& BUFFER_FLUSH
)
143 e_status_putc(ec
, '*');
145 e_status_putc(ec
, '(');
146 e_status_putc_string(ec
, ec
->view
->b
->name
);
148 for (i
= 0, rcol
= 0; i
< ec
->view
->b
->dot
; i
++) {
149 if (ec
->view
->b
->line
->text
[i
] == '\t')
154 sprintf(buf
, ") L(%d/%d) C(%d/%d) ", ec
->view
->b
->nl
, ec
->view
->b
->nlines
,
155 rcol
+1, ec
->view
->b
->line
->used
+1);
156 e_status_putc_string(ec
, buf
);
158 /* put the percent of the file. */
159 if (ec
->view
->b
->line
== ec
->view
->b
->lines
)
160 e_status_putc_string(ec
, "Top ");
161 else if (!ec
->view
->b
->line
->next
)
162 e_status_putc_string(ec
, "Bottom ");
164 int ratio
= (100L * ec
->view
->b
->nl
)/ec
->view
->b
->nlines
;
169 sprintf(buf
, "%2d%% ", ratio
);
170 e_status_putc_string(ec
, buf
);
173 e_status_putc_msg(ec
);
175 while (ec
->view
->stcol
< ec
->view
->rcol
)
176 e_status_putc(ec
, ' ');
178 e_term_move(orow
, ocol
);