Fix setting terminal title if t_ts and t_fs are not set
[cmus.git] / window.h
blobdc76e7e2be81005e964f6f7b658cbeaaf94445cf
1 /*
2 * Copyright 2004-2005 Timo Hirvonen
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
17 * 02111-1307, USA.
20 #ifndef _WINDOW_H
21 #define _WINDOW_H
23 #include <iter.h>
26 * window contains list of rows
27 * - the list is double linked circular list
28 * - head contains no data. head is not a real row
29 * - head->prev gets the last row (or head if the list is empty) in the list
30 * - head->next gets the first row (or head if the list is empty) in the list
32 * get_prev(&iter) always stores prev row to the iter
33 * get_next(&iter) always stores next row to the iter
35 * these return 1 if the new row is real row (not head), 0 otherwise
37 * sel_changed callback is called if not NULL and selection has changed
40 struct window {
41 /* head of the row list */
42 struct iter head;
44 /* top row */
45 struct iter top;
47 /* selected row */
48 struct iter sel;
50 /* window height */
51 int nr_rows;
53 unsigned changed : 1;
55 /* return 1 if got next/prev, otherwise 0 */
56 int (*get_prev)(struct iter *iter);
57 int (*get_next)(struct iter *iter);
58 void (*sel_changed)(void);
61 extern struct window *window_new(int (*get_prev)(struct iter *), int (*get_next)(struct iter *));
62 extern void window_free(struct window *win);
63 extern void window_set_empty(struct window *win);
64 extern void window_set_contents(struct window *win, void *head);
66 /* call this after rows were added to window or order of rows was changed.
67 * top and sel MUST point to valid rows (or window must be empty, but then
68 * why do you want to call this function :)).
70 * if you remove row from window then call window_row_vanishes BEFORE removing
71 * the row instead of this function.
73 extern void window_changed(struct window *win);
75 /* call this BEFORE row is removed from window */
76 extern void window_row_vanishes(struct window *win, struct iter *iter);
78 extern int window_get_top(struct window *win, struct iter *iter);
79 extern int window_get_sel(struct window *win, struct iter *iter);
80 extern int window_get_prev(struct window *win, struct iter *iter);
81 extern int window_get_next(struct window *win, struct iter *iter);
83 /* set selected row */
84 extern void window_set_sel(struct window *win, struct iter *iter);
86 extern void window_set_nr_rows(struct window *win, int nr_rows);
87 extern void window_up(struct window *win, int rows);
88 extern void window_down(struct window *win, int rows);
89 extern void window_goto_top(struct window *win);
90 extern void window_goto_bottom(struct window *win);
91 extern void window_page_up(struct window *win);
92 extern void window_page_down(struct window *win);
94 extern int window_get_nr_rows(struct window *win);
96 #endif