scrollpad: make m_beginning unsigned
This commit is contained in:
@@ -35,17 +35,10 @@ Scrollpad::Scrollpad(size_t startx,
|
||||
m_beginning(0),
|
||||
m_found_value_begin(-1),
|
||||
m_found_value_end(-1),
|
||||
m_real_height(1)
|
||||
m_real_height(height)
|
||||
{
|
||||
}
|
||||
|
||||
Scrollpad::Scrollpad(const Scrollpad &s) : Window(s)
|
||||
{
|
||||
m_buffer << s.m_buffer;
|
||||
m_beginning = s.m_beginning;
|
||||
m_real_height = s.m_real_height;
|
||||
}
|
||||
|
||||
void Scrollpad::flush()
|
||||
{
|
||||
m_real_height = 1;
|
||||
@@ -124,10 +117,9 @@ void Scrollpad::removeFormatting()
|
||||
|
||||
void Scrollpad::refresh()
|
||||
{
|
||||
int MaxBeginning = m_real_height-m_height;
|
||||
assert(MaxBeginning >= 0);
|
||||
if (m_beginning > MaxBeginning)
|
||||
m_beginning = MaxBeginning;
|
||||
assert(m_real_height >= m_real_height);
|
||||
size_t max_beginning = m_real_height - m_height;
|
||||
m_beginning = std::min(m_beginning, max_beginning);
|
||||
prefresh(m_window, m_beginning, 0, m_start_y, m_start_x, m_start_y+m_height-1, m_start_x+m_width-1);
|
||||
}
|
||||
|
||||
@@ -139,34 +131,33 @@ void Scrollpad::resize(size_t new_width, size_t new_height)
|
||||
|
||||
void Scrollpad::scroll(Where where)
|
||||
{
|
||||
int MaxBeginning = /*itsContent.size() < m_height ? 0 : */m_real_height-m_height;
|
||||
|
||||
assert(m_real_height >= m_height);
|
||||
size_t max_beginning = m_real_height - m_height;
|
||||
switch (where)
|
||||
{
|
||||
case wUp:
|
||||
{
|
||||
if (m_beginning > 0)
|
||||
m_beginning--;
|
||||
--m_beginning;
|
||||
break;
|
||||
}
|
||||
case wDown:
|
||||
{
|
||||
if (m_beginning < MaxBeginning)
|
||||
m_beginning++;
|
||||
if (m_beginning < max_beginning)
|
||||
++m_beginning;
|
||||
break;
|
||||
}
|
||||
case wPageUp:
|
||||
{
|
||||
m_beginning -= m_height;
|
||||
if (m_beginning < 0)
|
||||
if (m_beginning > m_height)
|
||||
m_beginning -= m_height;
|
||||
else
|
||||
m_beginning = 0;
|
||||
break;
|
||||
}
|
||||
case wPageDown:
|
||||
{
|
||||
m_beginning += m_height;
|
||||
if (m_beginning > MaxBeginning)
|
||||
m_beginning = MaxBeginning;
|
||||
m_beginning = std::min(m_beginning + m_height, max_beginning);
|
||||
break;
|
||||
}
|
||||
case wHome:
|
||||
@@ -176,7 +167,7 @@ void Scrollpad::scroll(Where where)
|
||||
}
|
||||
case wEnd:
|
||||
{
|
||||
m_beginning = MaxBeginning;
|
||||
m_beginning = max_beginning;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,6 @@ struct Scrollpad: public 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
|
||||
@@ -120,7 +116,7 @@ struct Scrollpad: public Window
|
||||
private:
|
||||
basic_buffer<my_char_t> m_buffer;
|
||||
|
||||
int m_beginning;
|
||||
size_t m_beginning;
|
||||
|
||||
bool m_found_for_each;
|
||||
bool m_found_case_sensitive;
|
||||
|
||||
Reference in New Issue
Block a user