/* $OpenBSD$ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/time.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "tmux.h"
char *status_redraw_get_left(
struct client *, time_t, int, struct grid_cell *, size_t *);
char *status_redraw_get_right(
struct client *, time_t, int, struct grid_cell *, size_t *);
char *status_find_job(struct client *, char **);
void status_job_free(void *);
void status_job_callback(struct job *);
char *status_print(
struct client *, struct winlink *, time_t, struct grid_cell *);
void status_replace1(struct client *, struct session *, struct winlink *,
struct window_pane *, char **, char **, char *, size_t, int);
void status_message_callback(int, short, void *);
const char *status_prompt_up_history(u_int *);
const char *status_prompt_down_history(u_int *);
void status_prompt_add_history(const char *);
char *status_prompt_complete(const char *);
/* Status prompt history. */
ARRAY_DECL(, char *) status_prompt_history = ARRAY_INITIALIZER;
/* Status output tree. */
RB_GENERATE(status_out_tree, status_out, entry, status_out_cmp);
/* Output tree comparison function. */
int
status_out_cmp(struct status_out *so1, struct status_out *so2)
{
return (strcmp(so1->cmd, so2->cmd));
}
/* Retrieve options for left string. */
char *
status_redraw_get_left(struct client *c,
time_t t, int utf8flag, struct grid_cell *gc, size_t *size)
{
struct session *s = c->session;
char *left;
u_char fg, bg, attr;
size_t leftlen;
fg = options_get_number(&s->options, "status-left-fg");
if (fg != 8)
colour_set_fg(gc, fg);
bg = options_get_number(&s->options, "status-left-bg");
if (bg != 8)
colour_set_bg(gc, bg);
attr = options_get_number(&s->options, "status-left-attr");
if (attr != 0)
gc->attr = attr;
left = status_replace(c, NULL,
NULL, NULL, options_get_string(&s->options, "status-left"), t, 1);
*size = options_get_number(&s->options, "status-left-length");
leftlen = screen_write_cstrlen(utf8flag, "%s", left);
if (leftlen < *size)
*size = leftlen;
return (left);
}
/* Retrieve options for right string. */
char *
status_redraw_get_right(struct client *c,
time_t t, int utf8flag, struct grid_cell *gc, size_t *size)
{
struct session *s = c->session;
char *right;
u_char fg, bg, attr;
size_t rightlen;
fg = options_get_number(&s->options, "status-right-fg");
if (fg != 8)
colour_set_fg(gc, fg);
bg = options_get_number(&s->options, "status-right-bg");
if (bg != 8)
colour_set_bg(gc, bg);
attr = options_get_number(&s->options, "status-right-attr");
if (attr != 0)
gc->attr = attr;
right = status_replace(c, NULL,
NULL, NULL, options_get_string(&s->options, "status-right"), t, 1);
*size = options_get_number(&s->options, "status-right-length");
rightlen = screen_write_cstrlen(utf8flag, "%s", right);
if (rightlen < *size)
*size = rightlen;
return (right);
}
/* Set window at window list position. */
void
status_set_window_at(struct client *c, u_int x)
{
struct session *s = c->session;
struct winlink *wl;
x += s->wlmouse;
RB_FOREACH(wl, winlinks, &s->windows) {
if (x < wl->status_width &&
session_select(s, wl->idx) == 0) {
server_redraw_session(s);
}
x -= wl->status_width + 1;
}
}
/* Draw status for client on the last lines of given context. */
int
status_redraw(struct client *c)
{
struct screen_write_ctx ctx;
struct session *s = c->session;
struct winlink *wl
|