Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/ncurses
File: cursesp.h
// * This makes emacs happy -*-Mode: C++;-*-
[0] Fix | Delete
/****************************************************************************
[1] Fix | Delete
* Copyright (c) 1998-2012,2014 Free Software Foundation, Inc. *
[2] Fix | Delete
* *
[3] Fix | Delete
* Permission is hereby granted, free of charge, to any person obtaining a *
[4] Fix | Delete
* copy of this software and associated documentation files (the *
[5] Fix | Delete
* "Software"), to deal in the Software without restriction, including *
[6] Fix | Delete
* without limitation the rights to use, copy, modify, merge, publish, *
[7] Fix | Delete
* distribute, distribute with modifications, sublicense, and/or sell *
[8] Fix | Delete
* copies of the Software, and to permit persons to whom the Software is *
[9] Fix | Delete
* furnished to do so, subject to the following conditions: *
[10] Fix | Delete
* *
[11] Fix | Delete
* The above copyright notice and this permission notice shall be included *
[12] Fix | Delete
* in all copies or substantial portions of the Software. *
[13] Fix | Delete
* *
[14] Fix | Delete
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
[15] Fix | Delete
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
[16] Fix | Delete
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
[17] Fix | Delete
* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
[18] Fix | Delete
* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
[19] Fix | Delete
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
[20] Fix | Delete
* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
[21] Fix | Delete
* *
[22] Fix | Delete
* Except as contained in this notice, the name(s) of the above copyright *
[23] Fix | Delete
* holders shall not be used in advertising or otherwise to promote the *
[24] Fix | Delete
* sale, use or other dealings in this Software without prior written *
[25] Fix | Delete
* authorization. *
[26] Fix | Delete
****************************************************************************/
[27] Fix | Delete
[28] Fix | Delete
/****************************************************************************
[29] Fix | Delete
* Author: Juergen Pfeifer, 1997 *
[30] Fix | Delete
****************************************************************************/
[31] Fix | Delete
[32] Fix | Delete
#ifndef NCURSES_CURSESP_H_incl
[33] Fix | Delete
#define NCURSES_CURSESP_H_incl 1
[34] Fix | Delete
[35] Fix | Delete
// $Id: cursesp.h,v 1.31 2014/08/09 22:06:26 Adam.Jiang Exp $
[36] Fix | Delete
[37] Fix | Delete
#include <cursesw.h>
[38] Fix | Delete
[39] Fix | Delete
extern "C" {
[40] Fix | Delete
# include <panel.h>
[41] Fix | Delete
}
[42] Fix | Delete
[43] Fix | Delete
class NCURSES_IMPEXP NCursesPanel
[44] Fix | Delete
: public NCursesWindow
[45] Fix | Delete
{
[46] Fix | Delete
protected:
[47] Fix | Delete
PANEL *p;
[48] Fix | Delete
static NCursesPanel *dummy;
[49] Fix | Delete
[50] Fix | Delete
private:
[51] Fix | Delete
// This structure is used for the panel's user data field to link the
[52] Fix | Delete
// PANEL* to the C++ object and to provide extra space for a user pointer.
[53] Fix | Delete
typedef struct {
[54] Fix | Delete
void* m_user; // the pointer for the user's data
[55] Fix | Delete
const NCursesPanel* m_back; // backward pointer to C++ object
[56] Fix | Delete
const PANEL* m_owner; // the panel itself
[57] Fix | Delete
} UserHook;
[58] Fix | Delete
[59] Fix | Delete
inline UserHook *UserPointer()
[60] Fix | Delete
{
[61] Fix | Delete
UserHook* uptr = reinterpret_cast<UserHook*>(
[62] Fix | Delete
const_cast<void *>(::panel_userptr (p)));
[63] Fix | Delete
return uptr;
[64] Fix | Delete
}
[65] Fix | Delete
[66] Fix | Delete
void init(); // Initialize the panel object
[67] Fix | Delete
[68] Fix | Delete
protected:
[69] Fix | Delete
void set_user(void *user)
[70] Fix | Delete
{
[71] Fix | Delete
UserHook* uptr = UserPointer();
[72] Fix | Delete
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p) {
[73] Fix | Delete
uptr->m_user = user;
[74] Fix | Delete
}
[75] Fix | Delete
}
[76] Fix | Delete
// Set the user pointer of the panel.
[77] Fix | Delete
[78] Fix | Delete
void *get_user()
[79] Fix | Delete
{
[80] Fix | Delete
UserHook* uptr = UserPointer();
[81] Fix | Delete
void *result = 0;
[82] Fix | Delete
if (uptr != 0 && uptr->m_back==this && uptr->m_owner==p)
[83] Fix | Delete
result = uptr->m_user;
[84] Fix | Delete
return result;
[85] Fix | Delete
}
[86] Fix | Delete
[87] Fix | Delete
void OnError (int err) const THROW2(NCursesException const, NCursesPanelException)
[88] Fix | Delete
{
[89] Fix | Delete
if (err==ERR)
[90] Fix | Delete
THROW(new NCursesPanelException (this, err));
[91] Fix | Delete
}
[92] Fix | Delete
// If err is equal to the curses error indicator ERR, an error handler
[93] Fix | Delete
// is called.
[94] Fix | Delete
[95] Fix | Delete
// Get a keystroke. Default implementation calls getch()
[96] Fix | Delete
virtual int getKey(void);
[97] Fix | Delete
[98] Fix | Delete
public:
[99] Fix | Delete
NCursesPanel(int nlines,
[100] Fix | Delete
int ncols,
[101] Fix | Delete
int begin_y = 0,
[102] Fix | Delete
int begin_x = 0)
[103] Fix | Delete
: NCursesWindow(nlines,ncols,begin_y,begin_x), p(0)
[104] Fix | Delete
{
[105] Fix | Delete
init();
[106] Fix | Delete
}
[107] Fix | Delete
// Create a panel with this size starting at the requested position.
[108] Fix | Delete
[109] Fix | Delete
NCursesPanel()
[110] Fix | Delete
: NCursesWindow(::stdscr), p(0)
[111] Fix | Delete
{
[112] Fix | Delete
init();
[113] Fix | Delete
}
[114] Fix | Delete
// This constructor creates the default Panel associated with the
[115] Fix | Delete
// ::stdscr window
[116] Fix | Delete
[117] Fix | Delete
NCursesPanel& operator=(const NCursesPanel& rhs)
[118] Fix | Delete
{
[119] Fix | Delete
if (this != &rhs) {
[120] Fix | Delete
*this = rhs;
[121] Fix | Delete
NCursesWindow::operator=(rhs);
[122] Fix | Delete
}
[123] Fix | Delete
return *this;
[124] Fix | Delete
}
[125] Fix | Delete
[126] Fix | Delete
NCursesPanel(const NCursesPanel& rhs)
[127] Fix | Delete
: NCursesWindow(rhs),
[128] Fix | Delete
p(rhs.p)
[129] Fix | Delete
{
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
virtual ~NCursesPanel();
[133] Fix | Delete
[134] Fix | Delete
// basic manipulation
[135] Fix | Delete
inline void hide()
[136] Fix | Delete
{
[137] Fix | Delete
OnError (::hide_panel(p));
[138] Fix | Delete
}
[139] Fix | Delete
// Hide the panel. It stays in the stack but becomes invisible.
[140] Fix | Delete
[141] Fix | Delete
inline void show()
[142] Fix | Delete
{
[143] Fix | Delete
OnError (::show_panel(p));
[144] Fix | Delete
}
[145] Fix | Delete
// Show the panel, i.e. make it visible.
[146] Fix | Delete
[147] Fix | Delete
inline void top()
[148] Fix | Delete
{
[149] Fix | Delete
OnError (::top_panel(p));
[150] Fix | Delete
}
[151] Fix | Delete
// Make this panel the top panel in the stack.
[152] Fix | Delete
[153] Fix | Delete
inline void bottom()
[154] Fix | Delete
{
[155] Fix | Delete
OnError (::bottom_panel(p));
[156] Fix | Delete
}
[157] Fix | Delete
// Make this panel the bottom panel in the stack.
[158] Fix | Delete
// N.B.: The panel associated with ::stdscr is always on the bottom. So
[159] Fix | Delete
// actually bottom() makes the panel the first above ::stdscr.
[160] Fix | Delete
[161] Fix | Delete
virtual int mvwin(int y, int x)
[162] Fix | Delete
{
[163] Fix | Delete
OnError(::move_panel(p, y, x));
[164] Fix | Delete
return OK;
[165] Fix | Delete
}
[166] Fix | Delete
[167] Fix | Delete
inline bool hidden() const
[168] Fix | Delete
{
[169] Fix | Delete
return (::panel_hidden (p) ? TRUE : FALSE);
[170] Fix | Delete
}
[171] Fix | Delete
// Return TRUE if the panel is hidden, FALSE otherwise.
[172] Fix | Delete
[173] Fix | Delete
/* The functions panel_above() and panel_below() are not reflected in
[174] Fix | Delete
the NCursesPanel class. The reason for this is, that we cannot
[175] Fix | Delete
assume that a panel retrieved by those operations is one wrapped
[176] Fix | Delete
by a C++ class. Although this situation might be handled, we also
[177] Fix | Delete
need a reverse mapping from PANEL to NCursesPanel which needs some
[178] Fix | Delete
redesign of the low level stuff. At the moment, we define them in the
[179] Fix | Delete
interface but they will always produce an error. */
[180] Fix | Delete
inline NCursesPanel& above() const
[181] Fix | Delete
{
[182] Fix | Delete
OnError(ERR);
[183] Fix | Delete
return *dummy;
[184] Fix | Delete
}
[185] Fix | Delete
[186] Fix | Delete
inline NCursesPanel& below() const
[187] Fix | Delete
{
[188] Fix | Delete
OnError(ERR);
[189] Fix | Delete
return *dummy;
[190] Fix | Delete
}
[191] Fix | Delete
[192] Fix | Delete
// Those two are rewrites of the corresponding virtual members of
[193] Fix | Delete
// NCursesWindow
[194] Fix | Delete
virtual int refresh();
[195] Fix | Delete
// Propagate all panel changes to the virtual screen and update the
[196] Fix | Delete
// physical screen.
[197] Fix | Delete
[198] Fix | Delete
virtual int noutrefresh();
[199] Fix | Delete
// Propagate all panel changes to the virtual screen.
[200] Fix | Delete
[201] Fix | Delete
static void redraw();
[202] Fix | Delete
// Redraw all panels.
[203] Fix | Delete
[204] Fix | Delete
// decorations
[205] Fix | Delete
virtual void frame(const char* title=NULL,
[206] Fix | Delete
const char* btitle=NULL);
[207] Fix | Delete
// Put a frame around the panel and put the title centered in the top line
[208] Fix | Delete
// and btitle in the bottom line.
[209] Fix | Delete
[210] Fix | Delete
virtual void boldframe(const char* title=NULL,
[211] Fix | Delete
const char* btitle=NULL);
[212] Fix | Delete
// Same as frame(), but use highlighted attributes.
[213] Fix | Delete
[214] Fix | Delete
virtual void label(const char* topLabel,
[215] Fix | Delete
const char* bottomLabel);
[216] Fix | Delete
// Put the title centered in the top line and btitle in the bottom line.
[217] Fix | Delete
[218] Fix | Delete
virtual void centertext(int row,const char* label);
[219] Fix | Delete
// Put the label text centered in the specified row.
[220] Fix | Delete
};
[221] Fix | Delete
[222] Fix | Delete
/* We use templates to provide a typesafe mechanism to associate
[223] Fix | Delete
* user data with a panel. A NCursesUserPanel<T> is a panel
[224] Fix | Delete
* associated with some user data of type T.
[225] Fix | Delete
*/
[226] Fix | Delete
template<class T> class NCursesUserPanel : public NCursesPanel
[227] Fix | Delete
{
[228] Fix | Delete
public:
[229] Fix | Delete
NCursesUserPanel (int nlines,
[230] Fix | Delete
int ncols,
[231] Fix | Delete
int begin_y = 0,
[232] Fix | Delete
int begin_x = 0,
[233] Fix | Delete
const T* p_UserData = STATIC_CAST(T*)(0))
[234] Fix | Delete
: NCursesPanel (nlines, ncols, begin_y, begin_x)
[235] Fix | Delete
{
[236] Fix | Delete
if (p)
[237] Fix | Delete
set_user (const_cast<void *>(reinterpret_cast<const void*>
[238] Fix | Delete
(p_UserData)));
[239] Fix | Delete
};
[240] Fix | Delete
// This creates an user panel of the requested size with associated
[241] Fix | Delete
// user data pointed to by p_UserData.
[242] Fix | Delete
[243] Fix | Delete
NCursesUserPanel(const T* p_UserData = STATIC_CAST(T*)(0)) : NCursesPanel()
[244] Fix | Delete
{
[245] Fix | Delete
if (p)
[246] Fix | Delete
set_user(const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
[247] Fix | Delete
};
[248] Fix | Delete
// This creates an user panel associated with the ::stdscr and user data
[249] Fix | Delete
// pointed to by p_UserData.
[250] Fix | Delete
[251] Fix | Delete
virtual ~NCursesUserPanel() {};
[252] Fix | Delete
[253] Fix | Delete
T* UserData (void)
[254] Fix | Delete
{
[255] Fix | Delete
return reinterpret_cast<T*>(get_user ());
[256] Fix | Delete
};
[257] Fix | Delete
// Retrieve the user data associated with the panel.
[258] Fix | Delete
[259] Fix | Delete
virtual void setUserData (const T* p_UserData)
[260] Fix | Delete
{
[261] Fix | Delete
if (p)
[262] Fix | Delete
set_user (const_cast<void *>(reinterpret_cast<const void*>(p_UserData)));
[263] Fix | Delete
}
[264] Fix | Delete
// Associate the user panel with the user data pointed to by p_UserData.
[265] Fix | Delete
};
[266] Fix | Delete
[267] Fix | Delete
#endif /* NCURSES_CURSESP_H_incl */
[268] Fix | Delete
[269] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function