Code

Spelling corrections
[ncmpc.git] / src / screen_text.h
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #ifndef SCREEN_TEXT_H
21 #define SCREEN_TEXT_H
23 #include "list_window.h"
25 #include <glib.h>
27 struct mpdclient;
29 struct screen_text {
30         GPtrArray *lines;
32         struct list_window *lw;
33 };
35 static inline void
36 screen_text_init(struct screen_text *text, WINDOW *w, int cols, int rows)
37 {
38         text->lines = g_ptr_array_new();
40         text->lw = list_window_init(w, cols, rows);
41         text->lw->hide_cursor = true;
42 }
44 void
45 screen_text_clear(struct screen_text *text);
47 static inline void
48 screen_text_deinit(struct screen_text *text)
49 {
50         screen_text_clear(text);
51         g_ptr_array_free(text->lines, TRUE);
53         list_window_free(text->lw);
54 }
56 static inline void
57 screen_text_resize(struct screen_text *text, int cols, int rows)
58 {
59         text->lw->cols = cols;
60         text->lw->rows = rows;
61 }
63 static inline bool
64 screen_text_is_empty(const struct screen_text *text)
65 {
66         return text->lines->len == 0;
67 }
69 void
70 screen_text_set(struct screen_text *text, const GString *str);
72 const char *
73 screen_text_list_callback(unsigned idx, bool *highlight, void *data);
75 static inline void
76 screen_text_paint(struct screen_text *text)
77 {
78         list_window_paint(text->lw, screen_text_list_callback, text);
79 }
81 /**
82  * Repaint and update the screen.
83  */
84 static inline void
85 screen_text_repaint(struct screen_text *text)
86 {
87         screen_text_paint(text);
88         wrefresh(text->lw->w);
89 }
91 bool
92 screen_text_cmd(struct screen_text *text, struct mpdclient *c, command_t cmd);
94 #endif