File: scroller.h

package info (click to toggle)
crawl 2%3A0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,188 kB
  • sloc: cpp: 363,709; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (67 lines) | stat: -rw-r--r-- 1,592 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
 * @file
 * @brief Formatted scroller
**/

#pragma once

#include "menu.h"
#include "ui.h"
#include "maybe-bool.h"

enum FSFlag {
    FS_START_AT_END = 0x01,
    FS_PREWRAPPED_TEXT = 0x02,
    FS_EASY_EXIT = 0x04,
};

class formatted_scroller
{
public:
    formatted_scroller(int flags, const string& text = "")
        : m_lastch(0), m_flags(0x0), m_scroll(0)
    {
        m_flags = flags;
        add_text(text);
    };
    formatted_scroller(const string& text = "") : formatted_scroller(0, text) {};

    virtual void add_formatted_string(const formatted_string& s, bool new_line = false);
    virtual void add_text(const string& s, bool new_line = false);
    virtual void add_raw_text(const string& s, bool new_line = false);

    virtual int show();
    int get_lastch() { return m_lastch; }

    void set_tag(const string& tag) { m_tag = tag; }

    void set_more() { m_more.clear(); }
    void set_more(formatted_string more) { m_more = std::move(more); }

    void set_title() { m_title.clear(); };
    void set_title(formatted_string title) { m_title = std::move(title); };

    void scroll_to_end();
    void set_scroll(int y);

    const formatted_string& get_contents() { return contents; };

    string highlight;

protected:

    formatted_string contents;
    string m_tag;
    formatted_string m_title;
    formatted_string m_more;
    int m_lastch;
    int m_flags;
    int m_scroll;

    bool m_contents_dirty, m_scroll_dirty;

    virtual maybe_bool process_key(int keyin);
    shared_ptr<ui::Scroller> m_scroller;
};

void recv_formatted_scroller_scroll(int line);