scrollpad: adjust indentation in header file
This commit is contained in:
210
src/scrollpad.h
210
src/scrollpad.h
@@ -24,113 +24,113 @@
|
|||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "strbuffer.h"
|
#include "strbuffer.h"
|
||||||
|
|
||||||
namespace NC
|
namespace NC {//
|
||||||
|
|
||||||
|
/// Scrollpad is specialized window that can hold large portion of text and
|
||||||
|
/// supports scrolling if the amount of it is bigger than the window area.
|
||||||
|
struct Scrollpad: public Window
|
||||||
{
|
{
|
||||||
/// Scrollpad is specialized window that can hold large portion of text and
|
/// Constructs an empty scrollpad with given parameters
|
||||||
/// supports scrolling if the amount of it is bigger than the window area.
|
/// @param startx X position of left upper corner of constructed window
|
||||||
class Scrollpad: public Window
|
/// @param starty Y position of left upper corner of constructed window
|
||||||
|
/// @param width width of constructed window
|
||||||
|
/// @param height height of constructed window
|
||||||
|
/// @param title title of constructed window
|
||||||
|
/// @param color base color of constructed window
|
||||||
|
/// @param border border of constructed window
|
||||||
|
Scrollpad(size_t startx, size_t starty, size_t width, size_t height,
|
||||||
|
const std::string &title, Color color, Border border);
|
||||||
|
|
||||||
|
/// Copies the scrollpad
|
||||||
|
/// @param s copied scrollpad
|
||||||
|
Scrollpad(const Scrollpad &s);
|
||||||
|
|
||||||
|
/// Prints the text stored in internal buffer to window. Note that
|
||||||
|
/// all changes that has been made for text stored in scrollpad won't
|
||||||
|
/// be visible until one invokes this function
|
||||||
|
void flush();
|
||||||
|
|
||||||
|
/// Searches for given string in text and sets format/color at the
|
||||||
|
/// beginning and end of it using val_b and val_e flags accordingly
|
||||||
|
/// @param val_b flag set at the beginning of found occurence of string
|
||||||
|
/// @param s string that function seaches for
|
||||||
|
/// @param val_e flag set at the end of found occurence of string
|
||||||
|
/// @param case_sensitive indicates whether algorithm should care about case sensitivity
|
||||||
|
/// @param for_each indicates whether function searches through whole text and sets
|
||||||
|
/// given format for all occurences of given string or stops after first occurence
|
||||||
|
/// @return true if at least one occurence of the string was found, false otherwise
|
||||||
|
/// @see basic_buffer::setFormatting()
|
||||||
|
bool setFormatting(short val_b, const std::basic_string<my_char_t> &s,
|
||||||
|
short val_e, bool case_sensitive, bool for_each = 1);
|
||||||
|
|
||||||
|
/// Removes all format flags and colors from stored text
|
||||||
|
void forgetFormatting();
|
||||||
|
|
||||||
|
/// Removes all format flags and colors that was applied
|
||||||
|
/// by the most recent call to setFormatting() function
|
||||||
|
/// @see setFormatting()
|
||||||
|
/// @see basic_buffer::removeFormatting()
|
||||||
|
void removeFormatting();
|
||||||
|
|
||||||
|
/// @return text stored in internal buffer
|
||||||
|
///
|
||||||
|
const std::basic_string<my_char_t> &content() { return m_buffer.str(); }
|
||||||
|
|
||||||
|
/// Refreshes the window
|
||||||
|
/// @see Window::Refresh()
|
||||||
|
///
|
||||||
|
virtual void refresh();
|
||||||
|
|
||||||
|
/// Scrolls by given amount of lines
|
||||||
|
/// @param where indicates where exactly one wants to go
|
||||||
|
/// @see Window::Scroll()
|
||||||
|
///
|
||||||
|
virtual void scroll(Where where);
|
||||||
|
|
||||||
|
/// Resizes the window
|
||||||
|
/// @param new_width new window's width
|
||||||
|
/// @param new_height new window's height
|
||||||
|
/// @see Window::Resize()
|
||||||
|
///
|
||||||
|
virtual void resize(size_t new_width, size_t new_height);
|
||||||
|
|
||||||
|
/// Cleares the content of scrollpad
|
||||||
|
/// @see Window::clear()
|
||||||
|
///
|
||||||
|
virtual void clear();
|
||||||
|
|
||||||
|
/// Sets starting position to the beginning
|
||||||
|
///
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
/// Template function that redirects all data passed
|
||||||
|
/// to the scrollpad window to its internal buffer
|
||||||
|
/// @param obj any object that has ostream &operator<<() defined
|
||||||
|
/// @return reference to itself
|
||||||
|
///
|
||||||
|
template <typename T> Scrollpad &operator<<(const T &obj)
|
||||||
{
|
{
|
||||||
public:
|
m_buffer << obj;
|
||||||
/// Constructs an empty scrollpad with given parameters
|
return *this;
|
||||||
/// @param startx X position of left upper corner of constructed window
|
}
|
||||||
/// @param starty Y position of left upper corner of constructed window
|
# ifdef _UTF8
|
||||||
/// @param width width of constructed window
|
Scrollpad &operator<<(const std::string &s);
|
||||||
/// @param height height of constructed window
|
# endif // _UTF8
|
||||||
/// @param title title of constructed window
|
|
||||||
/// @param color base color of constructed window
|
private:
|
||||||
/// @param border border of constructed window
|
basic_buffer<my_char_t> m_buffer;
|
||||||
Scrollpad(size_t startx, size_t starty, size_t width, size_t height,
|
|
||||||
const std::string &title, Color color, Border border);
|
int m_beginning;
|
||||||
|
|
||||||
/// Copies the scrollpad
|
bool m_found_for_each;
|
||||||
/// @param s copied scrollpad
|
bool m_found_case_sensitive;
|
||||||
Scrollpad(const Scrollpad &s);
|
short m_found_value_begin;
|
||||||
|
short m_found_value_end;
|
||||||
/// Prints the text stored in internal buffer to window. Note that
|
std::basic_string<my_char_t> m_found_pattern;
|
||||||
/// all changes that has been made for text stored in scrollpad won't
|
|
||||||
/// be visible until one invokes this function
|
size_t m_real_height;
|
||||||
void flush();
|
};
|
||||||
|
|
||||||
/// Searches for given string in text and sets format/color at the
|
|
||||||
/// beginning and end of it using val_b and val_e flags accordingly
|
|
||||||
/// @param val_b flag set at the beginning of found occurence of string
|
|
||||||
/// @param s string that function seaches for
|
|
||||||
/// @param val_e flag set at the end of found occurence of string
|
|
||||||
/// @param case_sensitive indicates whether algorithm should care about case sensitivity
|
|
||||||
/// @param for_each indicates whether function searches through whole text and sets
|
|
||||||
/// given format for all occurences of given string or stops after first occurence
|
|
||||||
/// @return true if at least one occurence of the string was found, false otherwise
|
|
||||||
/// @see basic_buffer::setFormatting()
|
|
||||||
bool setFormatting(short val_b, const std::basic_string<my_char_t> &s,
|
|
||||||
short val_e, bool case_sensitive, bool for_each = 1);
|
|
||||||
|
|
||||||
/// Removes all format flags and colors from stored text
|
|
||||||
void forgetFormatting();
|
|
||||||
|
|
||||||
/// Removes all format flags and colors that was applied
|
|
||||||
/// by the most recent call to setFormatting() function
|
|
||||||
/// @see setFormatting()
|
|
||||||
/// @see basic_buffer::removeFormatting()
|
|
||||||
void removeFormatting();
|
|
||||||
|
|
||||||
/// @return text stored in internal buffer
|
|
||||||
///
|
|
||||||
const std::basic_string<my_char_t> &content() { return m_buffer.str(); }
|
|
||||||
|
|
||||||
/// Refreshes the window
|
|
||||||
/// @see Window::Refresh()
|
|
||||||
///
|
|
||||||
virtual void refresh();
|
|
||||||
|
|
||||||
/// Scrolls by given amount of lines
|
|
||||||
/// @param where indicates where exactly one wants to go
|
|
||||||
/// @see Window::Scroll()
|
|
||||||
///
|
|
||||||
virtual void scroll(Where where);
|
|
||||||
|
|
||||||
/// Resizes the window
|
|
||||||
/// @param new_width new window's width
|
|
||||||
/// @param new_height new window's height
|
|
||||||
/// @see Window::Resize()
|
|
||||||
///
|
|
||||||
virtual void resize(size_t new_width, size_t new_height);
|
|
||||||
|
|
||||||
/// Cleares the content of scrollpad
|
|
||||||
/// @see Window::clear()
|
|
||||||
///
|
|
||||||
virtual void clear();
|
|
||||||
|
|
||||||
/// Sets starting position to the beginning
|
|
||||||
///
|
|
||||||
void reset();
|
|
||||||
|
|
||||||
/// Template function that redirects all data passed
|
|
||||||
/// to the scrollpad window to its internal buffer
|
|
||||||
/// @param obj any object that has ostream &operator<<() defined
|
|
||||||
/// @return reference to itself
|
|
||||||
///
|
|
||||||
template <typename T> Scrollpad &operator<<(const T &obj)
|
|
||||||
{
|
|
||||||
m_buffer << obj;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
# ifdef _UTF8
|
|
||||||
Scrollpad &operator<<(const std::string &s);
|
|
||||||
# endif // _UTF8
|
|
||||||
|
|
||||||
private:
|
|
||||||
basic_buffer<my_char_t> m_buffer;
|
|
||||||
|
|
||||||
int m_beginning;
|
|
||||||
|
|
||||||
bool m_found_for_each;
|
|
||||||
bool m_found_case_sensitive;
|
|
||||||
short m_found_value_begin;
|
|
||||||
short m_found_value_end;
|
|
||||||
std::basic_string<my_char_t> m_found_pattern;
|
|
||||||
|
|
||||||
size_t m_real_height;
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ namespace NC {//
|
|||||||
/// window or taken as raw string at any time.
|
/// window or taken as raw string at any time.
|
||||||
template <typename C> class basic_buffer
|
template <typename C> class basic_buffer
|
||||||
{
|
{
|
||||||
friend class Scrollpad;
|
friend struct Scrollpad;
|
||||||
|
|
||||||
/// Struct used for storing information about
|
/// Struct used for storing information about
|
||||||
/// one color/format flag along with its position
|
/// one color/format flag along with its position
|
||||||
|
|||||||
Reference in New Issue
Block a user