File: curs.h

package info (click to toggle)
yapet 2.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 11,920 kB
  • sloc: cpp: 32,397; sh: 5,032; makefile: 880; ansic: 36; sed: 16
file content (155 lines) | stat: -rw-r--r-- 3,760 bytes parent folder | download | duplicates (4)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// -*- mode: c++ -*-
//
// This file is part of libyacurs.
// Copyright (C) 2013  Rafael Ostertag
//
// This program is free software: you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see
// <http://www.gnu.org/licenses/>.
//
//
// $Id$

#ifndef CURS_H
#define CURS_H 1

#include <string>

#include "area.h"
#include "event.h"
#include "statusbar.h"
#include "titlebar.h"
#include "window.h"
#include "yacurscurses.h"

/**
 * General name space of libyacurs.
 */
namespace YACURS {
/**
 * Static class for starting/stopping Curses.
 *
 * Class taking care of initializing and unitializing curses, and
 * running the application.
 *
 * It takes care of showing a title, status line, and/or main
 * window.
 */
class Curses {
   private:
    /**
     * Screen size before suspending.
     *
     * Before suspending on SIGTSTP, the current screen size
     * will be saved. When resumed by SIGCONT, the current
     * screen size will be compared to this, and a resize
     * performed if they differ.
     */
    static Size suspend_scrsz;

    /**
     * Pointer to StatusBar.
     *
     * Curses will not free the memory associated with StatuLine.
     */
    static StatusBar* _statusBar;

    /**
     * Pointer to a title LineObject.
     *
     * Curses will not free the memory associated with LineObject.
     */
    static TitleBar* _titleBar;

    /**
     * Pointer to the main window.
     *
     * Curses will not free the memory associated with Window.
     */
    static Window* _mainWindow;

    /**
     * Flag indicating whether or not Curses has been initialized.
     *
     * It will be set by init() and removed by end().
     */
    static bool initialized;

    /**
     * Flag indicating whether or not program has been suspended.
     */
    static volatile bool _suspended;

    /**
     * The terminals we know
     *
     * Holds the terminals we know that can have set the
     * title.
     */
    static const char* _xterm_list[];

    static bool is_xterm();

   protected:
    /**
     * Handler for EVT_DOUPDATE event.
     *
     * @param e doupdate event.
     */
    static void doupdate_handler(Event& e);

    static void termresetup_handler(Event& e);

    static void sigtstp_handler(Event& e);

    static void sigcont_handler(Event& e);

   public:
    static void init(const std::string& colors = std::string());

    static void end();

    /**
     * Start the application.
     *
     * Starts the application by initializing the Focus Manager,
     * showing the title, status line and main window (if any),
     * and starting the EventQueue..
     *
     * Upon termination of the EventQueue by an EVT_QUIT event,
     * the title, status line and main window (if any) will be
     * closed and the Focus Manager will be uninitialized.
     */
    static void run();

    static void title(TitleBar* titleBar);

    static TitleBar* title();

    static void statusbar(StatusBar* statusBar);

    static StatusBar* statusbar();

    static void mainwindow(Window* window);

    static Window* mainwindow();

    static Size current_screensize();

    static Size inquiry_screensize();

    static void set_terminal_title(const std::string& title);
};
}  // namespace YACURS

#endif