ncmpc  0.30
BasicMarquee.hxx
Go to the documentation of this file.
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2018 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.
9  *
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.
14  *
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  */
19 
20 #ifndef BASIC_MARQUEE_HXX
21 #define BASIC_MARQUEE_HXX
22 
29 class BasicMarquee {
30  const char *const separator;
31 
35  unsigned width;
36 
40  unsigned text_utf8_length;
41 
45  char *text = nullptr;
46 
50  char *text_utf8 = nullptr;
51 
56  unsigned offset;
57 
58 public:
59  BasicMarquee(const char *_separator)
60  :separator(_separator) {}
61 
62  bool IsDefined() const {
63  return text != nullptr;
64  }
65 
71  bool Set(unsigned width, const char *text);
72 
76  void Clear();
77 
78  void Rewind() {
79  offset = 0;
80  }
81 
82  void Step() {
83  ++offset;
84 
85  if (offset >= text_utf8_length / 2)
86  offset = 0;
87  }
88 
89  char *ScrollString() const;
90 };
91 
92 #endif
Definition: BasicMarquee.hxx:29
char * ScrollString() const
BasicMarquee(const char *_separator)
Definition: BasicMarquee.hxx:59
void Rewind()
Definition: BasicMarquee.hxx:78
bool Set(unsigned width, const char *text)
bool IsDefined() const
Definition: BasicMarquee.hxx:62
void Step()
Definition: BasicMarquee.hxx:82