use typename keyword instead of class as it's more logical
This commit is contained in:
@@ -29,12 +29,12 @@ namespace Display
|
|||||||
{
|
{
|
||||||
std::string Columns(std::string);
|
std::string Columns(std::string);
|
||||||
|
|
||||||
template <class T> void Generic(const T &t, void *, Menu<T> *menu)
|
template <typename T> void Generic(const T &t, void *, Menu<T> *menu)
|
||||||
{
|
{
|
||||||
*menu << t;
|
*menu << t;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class A, class B> void Pairs(const std::pair<A, B> &pair, void *, Menu< std::pair<A, B> > *menu)
|
template <typename A, typename B> void Pairs(const std::pair<A, B> &pair, void *, Menu< std::pair<A, B> > *menu)
|
||||||
{
|
{
|
||||||
*menu << pair.first;
|
*menu << pair.first;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ class CaseInsensitiveSorting
|
|||||||
bool operator()(MPD::Song *, MPD::Song *);
|
bool operator()(MPD::Song *, MPD::Song *);
|
||||||
bool operator()(const MPD::Item &, const MPD::Item &);
|
bool operator()(const MPD::Item &, const MPD::Item &);
|
||||||
|
|
||||||
template <class A, class B> bool operator()(const std::pair<A, B> &a, const std::pair<A, B> &b)
|
template <typename A, typename B> bool operator()(const std::pair<A, B> &a, const std::pair<A, B> &b)
|
||||||
{
|
{
|
||||||
std::string aa = a.first;
|
std::string aa = a.first;
|
||||||
std::string bb = b.first;
|
std::string bb = b.first;
|
||||||
@@ -47,7 +47,7 @@ class CaseInsensitiveSorting
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class A, class B> std::string StringPairToString(const std::pair<A, B> &pair, void *)
|
template <typename A, typename B> std::string StringPairToString(const std::pair<A, B> &pair, void *)
|
||||||
{
|
{
|
||||||
return pair.first;
|
return pair.first;
|
||||||
}
|
}
|
||||||
|
|||||||
94
src/menu.h
94
src/menu.h
@@ -66,7 +66,7 @@ namespace NCurses
|
|||||||
virtual bool isFiltered() = 0;
|
virtual bool isFiltered() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class T> class Menu : public Window, public List
|
template <typename T> class Menu : public Window, public List
|
||||||
{
|
{
|
||||||
typedef void (*ItemDisplayer) (const T &, void *, Menu<T> *);
|
typedef void (*ItemDisplayer) (const T &, void *, Menu<T> *);
|
||||||
typedef std::string (*GetStringFunction) (const T &, void *);
|
typedef std::string (*GetStringFunction) (const T &, void *);
|
||||||
@@ -83,7 +83,7 @@ namespace NCurses
|
|||||||
bool isStatic;
|
bool isStatic;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class Comparison> class InternalSorting
|
template <typename Comparison> class InternalSorting
|
||||||
{
|
{
|
||||||
Comparison cmp;
|
Comparison cmp;
|
||||||
|
|
||||||
@@ -151,7 +151,7 @@ namespace NCurses
|
|||||||
virtual void Reset();
|
virtual void Reset();
|
||||||
virtual void Clear(bool clrscr = 1);
|
virtual void Clear(bool clrscr = 1);
|
||||||
|
|
||||||
template <class Comparison> void Sort(size_t beginning = 0)
|
template <typename Comparison> void Sort(size_t beginning = 0)
|
||||||
{
|
{
|
||||||
if (itsOptions.empty())
|
if (itsOptions.empty())
|
||||||
return;
|
return;
|
||||||
@@ -209,7 +209,7 @@ namespace NCurses
|
|||||||
template <> std::string Menu<std::string>::GetOption(size_t pos);
|
template <> std::string Menu<std::string>::GetOption(size_t pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> NCurses::Menu<T>::Menu(size_t startx,
|
template <typename T> NCurses::Menu<T>::Menu(size_t startx,
|
||||||
size_t starty,
|
size_t starty,
|
||||||
size_t width,
|
size_t width,
|
||||||
size_t height,
|
size_t height,
|
||||||
@@ -231,7 +231,7 @@ template <class T> NCurses::Menu<T>::Menu(size_t startx,
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> NCurses::Menu<T>::Menu(const Menu &m) : Window(m)
|
template <typename T> NCurses::Menu<T>::Menu(const Menu &m) : Window(m)
|
||||||
{
|
{
|
||||||
itsOptions = m.itsOptions;
|
itsOptions = m.itsOptions;
|
||||||
itsItemDisplayer = m.itsItemDisplayer;
|
itsItemDisplayer = m.itsItemDisplayer;
|
||||||
@@ -242,18 +242,18 @@ template <class T> NCurses::Menu<T>::Menu(const Menu &m) : Window(m)
|
|||||||
highlightEnabled = m.highlightEnabled;
|
highlightEnabled = m.highlightEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> NCurses::Menu<T>::~Menu()
|
template <typename T> NCurses::Menu<T>::~Menu()
|
||||||
{
|
{
|
||||||
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Reserve(size_t size)
|
template <typename T> void NCurses::Menu<T>::Reserve(size_t size)
|
||||||
{
|
{
|
||||||
itsOptions.reserve(size);
|
itsOptions.reserve(size);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::ResizeBuffer(size_t size)
|
template <typename T> void NCurses::Menu<T>::ResizeBuffer(size_t size)
|
||||||
{
|
{
|
||||||
itsOptions.resize(size);
|
itsOptions.resize(size);
|
||||||
for (size_t i = 0; i < size; i++)
|
for (size_t i = 0; i < size; i++)
|
||||||
@@ -261,27 +261,27 @@ template <class T> void NCurses::Menu<T>::ResizeBuffer(size_t size)
|
|||||||
itsOptions[i] = new Option();
|
itsOptions[i] = new Option();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::AddOption(const T &item, bool is_bold, bool is_static)
|
template <typename T> void NCurses::Menu<T>::AddOption(const T &item, bool is_bold, bool is_static)
|
||||||
{
|
{
|
||||||
itsOptions.push_back(new Option(item, is_bold, is_static));
|
itsOptions.push_back(new Option(item, is_bold, is_static));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::AddSeparator()
|
template <typename T> void NCurses::Menu<T>::AddSeparator()
|
||||||
{
|
{
|
||||||
itsOptions.push_back(0);
|
itsOptions.push_back(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::InsertOption(size_t pos, const T &item, bool is_bold, bool is_static)
|
template <typename T> void NCurses::Menu<T>::InsertOption(size_t pos, const T &item, bool is_bold, bool is_static)
|
||||||
{
|
{
|
||||||
itsOptions.insert(itsOptions.begin()+pos, new Option(item, is_bold, is_static));
|
itsOptions.insert(itsOptions.begin()+pos, new Option(item, is_bold, is_static));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::InsertSeparator(size_t pos)
|
template <typename T> void NCurses::Menu<T>::InsertSeparator(size_t pos)
|
||||||
{
|
{
|
||||||
itsOptions.insert(itsOptions.begin()+pos, 0);
|
itsOptions.insert(itsOptions.begin()+pos, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::DeleteOption(size_t pos)
|
template <typename T> void NCurses::Menu<T>::DeleteOption(size_t pos)
|
||||||
{
|
{
|
||||||
if (itsOptions.empty())
|
if (itsOptions.empty())
|
||||||
return;
|
return;
|
||||||
@@ -304,26 +304,26 @@ template <class T> void NCurses::Menu<T>::DeleteOption(size_t pos)
|
|||||||
Window::Clear();
|
Window::Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::IntoSeparator(size_t pos)
|
template <typename T> void NCurses::Menu<T>::IntoSeparator(size_t pos)
|
||||||
{
|
{
|
||||||
delete itsOptions.at(pos);
|
delete itsOptions.at(pos);
|
||||||
itsOptions[pos] = 0;
|
itsOptions[pos] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::BoldOption(int index, bool bold)
|
template <typename T> void NCurses::Menu<T>::BoldOption(int index, bool bold)
|
||||||
{
|
{
|
||||||
if (!itsOptions.at(index))
|
if (!itsOptions.at(index))
|
||||||
return;
|
return;
|
||||||
itsOptions[index]->isBold = bold;
|
itsOptions[index]->isBold = bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <typename T>
|
||||||
void NCurses::Menu<T>::Swap(size_t one, size_t two)
|
void NCurses::Menu<T>::Swap(size_t one, size_t two)
|
||||||
{
|
{
|
||||||
std::swap(itsOptions.at(one), itsOptions.at(two));
|
std::swap(itsOptions.at(one), itsOptions.at(two));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Refresh()
|
template <typename T> void NCurses::Menu<T>::Refresh()
|
||||||
{
|
{
|
||||||
if (itsOptionsPtr->empty())
|
if (itsOptionsPtr->empty())
|
||||||
{
|
{
|
||||||
@@ -386,7 +386,7 @@ template <class T> void NCurses::Menu<T>::Refresh()
|
|||||||
Window::Refresh();
|
Window::Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Scroll(Where where)
|
template <typename T> void NCurses::Menu<T>::Scroll(Where where)
|
||||||
{
|
{
|
||||||
if (itsOptionsPtr->empty())
|
if (itsOptionsPtr->empty())
|
||||||
return;
|
return;
|
||||||
@@ -492,13 +492,13 @@ template <class T> void NCurses::Menu<T>::Scroll(Where where)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Reset()
|
template <typename T> void NCurses::Menu<T>::Reset()
|
||||||
{
|
{
|
||||||
itsHighlight = 0;
|
itsHighlight = 0;
|
||||||
itsBeginning = 0;
|
itsBeginning = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::ClearFiltered()
|
template <typename T> void NCurses::Menu<T>::ClearFiltered()
|
||||||
{
|
{
|
||||||
itsFilteredOptions.clear();
|
itsFilteredOptions.clear();
|
||||||
itsFilteredRealPositions.clear();
|
itsFilteredRealPositions.clear();
|
||||||
@@ -506,7 +506,7 @@ template <class T> void NCurses::Menu<T>::ClearFiltered()
|
|||||||
itsOptionsPtr = &itsOptions;
|
itsOptionsPtr = &itsOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Clear(bool clrscr)
|
template <typename T> void NCurses::Menu<T>::Clear(bool clrscr)
|
||||||
{
|
{
|
||||||
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
for (option_iterator it = itsOptions.begin(); it != itsOptions.end(); it++)
|
||||||
delete *it;
|
delete *it;
|
||||||
@@ -518,7 +518,7 @@ template <class T> void NCurses::Menu<T>::Clear(bool clrscr)
|
|||||||
Window::Clear();
|
Window::Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool NCurses::Menu<T>::isBold(int id)
|
template <typename T> bool NCurses::Menu<T>::isBold(int id)
|
||||||
{
|
{
|
||||||
id = id == -1 ? itsHighlight : id;
|
id = id == -1 ? itsHighlight : id;
|
||||||
if (!itsOptionsPtr->at(id))
|
if (!itsOptionsPtr->at(id))
|
||||||
@@ -526,21 +526,21 @@ template <class T> bool NCurses::Menu<T>::isBold(int id)
|
|||||||
return (*itsOptionsPtr)[id]->isBold;
|
return (*itsOptionsPtr)[id]->isBold;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Select(int id, bool value)
|
template <typename T> void NCurses::Menu<T>::Select(int id, bool value)
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->at(id))
|
if (!itsOptionsPtr->at(id))
|
||||||
return;
|
return;
|
||||||
(*itsOptionsPtr)[id]->isSelected = value;
|
(*itsOptionsPtr)[id]->isSelected = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Static(int id, bool value)
|
template <typename T> void NCurses::Menu<T>::Static(int id, bool value)
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->at(id))
|
if (!itsOptionsPtr->at(id))
|
||||||
return;
|
return;
|
||||||
(*itsOptionsPtr)[id]->isStatic = value;
|
(*itsOptionsPtr)[id]->isStatic = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool NCurses::Menu<T>::isSelected(int id) const
|
template <typename T> bool NCurses::Menu<T>::isSelected(int id) const
|
||||||
{
|
{
|
||||||
id = id == -1 ? itsHighlight : id;
|
id = id == -1 ? itsHighlight : id;
|
||||||
if (!itsOptionsPtr->at(id))
|
if (!itsOptionsPtr->at(id))
|
||||||
@@ -548,7 +548,7 @@ template <class T> bool NCurses::Menu<T>::isSelected(int id) const
|
|||||||
return (*itsOptionsPtr)[id]->isSelected;
|
return (*itsOptionsPtr)[id]->isSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool NCurses::Menu<T>::isStatic(int id) const
|
template <typename T> bool NCurses::Menu<T>::isStatic(int id) const
|
||||||
{
|
{
|
||||||
id = id == -1 ? itsHighlight : id;
|
id = id == -1 ? itsHighlight : id;
|
||||||
if (!itsOptionsPtr->at(id))
|
if (!itsOptionsPtr->at(id))
|
||||||
@@ -556,7 +556,7 @@ template <class T> bool NCurses::Menu<T>::isStatic(int id) const
|
|||||||
return (*itsOptionsPtr)[id]->isStatic;
|
return (*itsOptionsPtr)[id]->isStatic;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool NCurses::Menu<T>::hasSelected() const
|
template <typename T> bool NCurses::Menu<T>::hasSelected() const
|
||||||
{
|
{
|
||||||
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); it++)
|
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->end(); it++)
|
||||||
if (*it && (*it)->isSelected)
|
if (*it && (*it)->isSelected)
|
||||||
@@ -564,30 +564,30 @@ template <class T> bool NCurses::Menu<T>::hasSelected() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::GetSelected(std::vector<size_t> &v) const
|
template <typename T> void NCurses::Menu<T>::GetSelected(std::vector<size_t> &v) const
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < itsOptionsPtr->size(); i++)
|
for (size_t i = 0; i < itsOptionsPtr->size(); i++)
|
||||||
if ((*itsOptionsPtr)[i]->isSelected)
|
if ((*itsOptionsPtr)[i]->isSelected)
|
||||||
v.push_back(i);
|
v.push_back(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::Highlight(size_t pos)
|
template <typename T> void NCurses::Menu<T>::Highlight(size_t pos)
|
||||||
{
|
{
|
||||||
itsHighlight = pos;
|
itsHighlight = pos;
|
||||||
itsBeginning = pos-itsHeight/2;
|
itsBeginning = pos-itsHeight/2;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> size_t NCurses::Menu<T>::Size() const
|
template <typename T> size_t NCurses::Menu<T>::Size() const
|
||||||
{
|
{
|
||||||
return itsOptionsPtr->size();
|
return itsOptionsPtr->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> size_t NCurses::Menu<T>::Choice() const
|
template <typename T> size_t NCurses::Menu<T>::Choice() const
|
||||||
{
|
{
|
||||||
return itsHighlight;
|
return itsHighlight;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> size_t NCurses::Menu<T>::RealChoice() const
|
template <typename T> size_t NCurses::Menu<T>::RealChoice() const
|
||||||
{
|
{
|
||||||
size_t result = 0;
|
size_t result = 0;
|
||||||
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->begin()+itsHighlight; it++)
|
for (option_const_iterator it = itsOptionsPtr->begin(); it != itsOptionsPtr->begin()+itsHighlight; it++)
|
||||||
@@ -596,7 +596,7 @@ template <class T> size_t NCurses::Menu<T>::RealChoice() const
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> bool NCurses::Menu<T>::Search(const std::string &constraint, size_t beginning, int flags)
|
template <typename T> bool NCurses::Menu<T>::Search(const std::string &constraint, size_t beginning, int flags)
|
||||||
{
|
{
|
||||||
itsFound.clear();
|
itsFound.clear();
|
||||||
itsSearchConstraint.clear();
|
itsSearchConstraint.clear();
|
||||||
@@ -616,7 +616,7 @@ template <class T> bool NCurses::Menu<T>::Search(const std::string &constraint,
|
|||||||
return !itsFound.empty();
|
return !itsFound.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::NextFound(bool wrap)
|
template <typename T> void NCurses::Menu<T>::NextFound(bool wrap)
|
||||||
{
|
{
|
||||||
if (itsFound.empty())
|
if (itsFound.empty())
|
||||||
return;
|
return;
|
||||||
@@ -627,7 +627,7 @@ template <class T> void NCurses::Menu<T>::NextFound(bool wrap)
|
|||||||
Highlight(*itsFound.begin());
|
Highlight(*itsFound.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::PrevFound(bool wrap)
|
template <typename T> void NCurses::Menu<T>::PrevFound(bool wrap)
|
||||||
{
|
{
|
||||||
if (itsFound.empty())
|
if (itsFound.empty())
|
||||||
return;
|
return;
|
||||||
@@ -638,7 +638,7 @@ template <class T> void NCurses::Menu<T>::PrevFound(bool wrap)
|
|||||||
Highlight(*itsFound.rbegin());
|
Highlight(*itsFound.rbegin());
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> void NCurses::Menu<T>::ApplyFilter(const std::string &filter, size_t beginning, int flags)
|
template <typename T> void NCurses::Menu<T>::ApplyFilter(const std::string &filter, size_t beginning, int flags)
|
||||||
{
|
{
|
||||||
if (filter == itsFilter)
|
if (filter == itsFilter)
|
||||||
return;
|
return;
|
||||||
@@ -670,12 +670,12 @@ template <class T> void NCurses::Menu<T>::ApplyFilter(const std::string &filter,
|
|||||||
Window::Clear();
|
Window::Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> const std::string &NCurses::Menu<T>::GetFilter()
|
template <typename T> const std::string &NCurses::Menu<T>::GetFilter()
|
||||||
{
|
{
|
||||||
return itsFilter;
|
return itsFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> std::string NCurses::Menu<T>::GetOption(size_t pos)
|
template <typename T> std::string NCurses::Menu<T>::GetOption(size_t pos)
|
||||||
{
|
{
|
||||||
if (itsOptionsPtr->at(pos) && itsGetStringFunction)
|
if (itsOptionsPtr->at(pos) && itsGetStringFunction)
|
||||||
return itsGetStringFunction((*itsOptionsPtr)[pos]->Item, itsGetStringFunctionUserData);
|
return itsGetStringFunction((*itsOptionsPtr)[pos]->Item, itsGetStringFunctionUserData);
|
||||||
@@ -683,63 +683,63 @@ template <class T> std::string NCurses::Menu<T>::GetOption(size_t pos)
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T &NCurses::Menu<T>::Back()
|
template <typename T> T &NCurses::Menu<T>::Back()
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->back())
|
if (!itsOptionsPtr->back())
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return itsOptionsPtr->back()->Item;
|
return itsOptionsPtr->back()->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> const T &NCurses::Menu<T>::Back() const
|
template <typename T> const T &NCurses::Menu<T>::Back() const
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->back())
|
if (!itsOptionsPtr->back())
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return itsOptionsPtr->back()->Item;
|
return itsOptionsPtr->back()->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T &NCurses::Menu<T>::Current()
|
template <typename T> T &NCurses::Menu<T>::Current()
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->at(itsHighlight))
|
if (!itsOptionsPtr->at(itsHighlight))
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[itsHighlight]->Item;
|
return (*itsOptionsPtr)[itsHighlight]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> const T &NCurses::Menu<T>::Current() const
|
template <typename T> const T &NCurses::Menu<T>::Current() const
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->at(itsHighlight))
|
if (!itsOptionsPtr->at(itsHighlight))
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[itsHighlight]->Item;
|
return (*itsOptionsPtr)[itsHighlight]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T &NCurses::Menu<T>::at(size_t i)
|
template <typename T> T &NCurses::Menu<T>::at(size_t i)
|
||||||
{
|
{
|
||||||
if (!itsOptionsPtr->at(i))
|
if (!itsOptionsPtr->at(i))
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[i]->Item;
|
return (*itsOptionsPtr)[i]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> const T &NCurses::Menu<T>::at(size_t i) const
|
template <typename T> const T &NCurses::Menu<T>::at(size_t i) const
|
||||||
{
|
{
|
||||||
if (!itsOptions->at(i))
|
if (!itsOptions->at(i))
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[i]->Item;
|
return (*itsOptionsPtr)[i]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> const T &NCurses::Menu<T>::operator[](size_t i) const
|
template <typename T> const T &NCurses::Menu<T>::operator[](size_t i) const
|
||||||
{
|
{
|
||||||
if (!(*itsOptionsPtr)[i])
|
if (!(*itsOptionsPtr)[i])
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[i]->Item;
|
return (*itsOptionsPtr)[i]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> T &NCurses::Menu<T>::operator[](size_t i)
|
template <typename T> T &NCurses::Menu<T>::operator[](size_t i)
|
||||||
{
|
{
|
||||||
if (!(*itsOptionsPtr)[i])
|
if (!(*itsOptionsPtr)[i])
|
||||||
throw InvalidItem();
|
throw InvalidItem();
|
||||||
return (*itsOptionsPtr)[i]->Item;
|
return (*itsOptionsPtr)[i]->Item;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T> NCurses::Menu<T> *NCurses::Menu<T>::EmptyClone() const
|
template <typename T> NCurses::Menu<T> *NCurses::Menu<T>::EmptyClone() const
|
||||||
{
|
{
|
||||||
return new NCurses::Menu<T>(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder);
|
return new NCurses::Menu<T>(GetStartX(), GetStartY(), GetWidth(), GetHeight(), itsTitle, itsBaseColor, itsBorder);
|
||||||
}
|
}
|
||||||
|
|||||||
14
src/screen.h
14
src/screen.h
@@ -63,7 +63,7 @@ class BasicScreen
|
|||||||
bool hasToBeResized;
|
bool hasToBeResized;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class WindowType> class Screen : public BasicScreen
|
template <typename WindowType> class Screen : public BasicScreen
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Screen() : w(0) { }
|
Screen() : w(0) { }
|
||||||
@@ -82,32 +82,32 @@ template <class WindowType> class Screen : public BasicScreen
|
|||||||
WindowType *w;
|
WindowType *w;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <class WindowType> void *Screen<WindowType>::Cmp()
|
template <typename WindowType> void *Screen<WindowType>::Cmp()
|
||||||
{
|
{
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> WindowType *Screen<WindowType>::Main()
|
template <typename WindowType> WindowType *Screen<WindowType>::Main()
|
||||||
{
|
{
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> void Screen<WindowType>::Refresh()
|
template <typename WindowType> void Screen<WindowType>::Refresh()
|
||||||
{
|
{
|
||||||
w->Display();
|
w->Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> void Screen<WindowType>::RefreshWindow()
|
template <typename WindowType> void Screen<WindowType>::RefreshWindow()
|
||||||
{
|
{
|
||||||
w->Display();
|
w->Display();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> void Screen<WindowType>::ReadKey(int &input)
|
template <typename WindowType> void Screen<WindowType>::ReadKey(int &input)
|
||||||
{
|
{
|
||||||
w->ReadKey(input);
|
w->ReadKey(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class WindowType> void Screen<WindowType>::Scroll(Where where, const int *key)
|
template <typename WindowType> void Screen<WindowType>::Scroll(Where where, const int *key)
|
||||||
{
|
{
|
||||||
if (!Config.fancy_scrolling && key)
|
if (!Config.fancy_scrolling && key)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace NCurses
|
|||||||
virtual void Resize(size_t, size_t);
|
virtual void Resize(size_t, size_t);
|
||||||
virtual void Clear(bool = 1);
|
virtual void Clear(bool = 1);
|
||||||
|
|
||||||
template <class T> Scrollpad &operator<<(const T &t)
|
template <typename T> Scrollpad &operator<<(const T &t)
|
||||||
{
|
{
|
||||||
itsBuffer << t;
|
itsBuffer << t;
|
||||||
return *this;
|
return *this;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
namespace NCurses
|
namespace NCurses
|
||||||
{
|
{
|
||||||
template <class C> class basic_buffer
|
template <typename C> class basic_buffer
|
||||||
{
|
{
|
||||||
struct FormatPos
|
struct FormatPos
|
||||||
{
|
{
|
||||||
@@ -53,7 +53,7 @@ namespace NCurses
|
|||||||
void SetTemp(std::basic_string<C> *);
|
void SetTemp(std::basic_string<C> *);
|
||||||
void Clear();
|
void Clear();
|
||||||
|
|
||||||
template <class T> basic_buffer<C> &operator<<(const T &t)
|
template <typename T> basic_buffer<C> &operator<<(const T &t)
|
||||||
{
|
{
|
||||||
itsString << t;
|
itsString << t;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -71,12 +71,12 @@ namespace NCurses
|
|||||||
typedef basic_buffer<wchar_t> WBuffer;
|
typedef basic_buffer<wchar_t> WBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> std::basic_string<C> NCurses::basic_buffer<C>::Str() const
|
template <typename C> std::basic_string<C> NCurses::basic_buffer<C>::Str() const
|
||||||
{
|
{
|
||||||
return itsString.str();
|
return itsString.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> void NCurses::basic_buffer<C>::SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each)
|
template <typename C> void NCurses::basic_buffer<C>::SetFormatting(short vb, const std::basic_string<C> &s, short ve, bool for_each)
|
||||||
{
|
{
|
||||||
std::basic_string<C> base = itsString.str();
|
std::basic_string<C> base = itsString.str();
|
||||||
FormatPos fp;
|
FormatPos fp;
|
||||||
@@ -95,24 +95,24 @@ template <class C> void NCurses::basic_buffer<C>::SetFormatting(short vb, const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> void NCurses::basic_buffer<C>::SetTemp(std::basic_string<C> *tmp)
|
template <typename C> void NCurses::basic_buffer<C>::SetTemp(std::basic_string<C> *tmp)
|
||||||
{
|
{
|
||||||
itsTempString = tmp;
|
itsTempString = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> void NCurses::basic_buffer<C>::Clear()
|
template <typename C> void NCurses::basic_buffer<C>::Clear()
|
||||||
{
|
{
|
||||||
itsString.str(std::basic_string<C>());
|
itsString.str(std::basic_string<C>());
|
||||||
itsFormat.clear();
|
itsFormat.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(std::ostream &(*os)(std::ostream&))
|
template <typename C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(std::ostream &(*os)(std::ostream&))
|
||||||
{
|
{
|
||||||
itsString << os;
|
itsString << os;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Color &color)
|
template <typename C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Color &color)
|
||||||
{
|
{
|
||||||
FormatPos f;
|
FormatPos f;
|
||||||
f.Position = itsString.str().length();
|
f.Position = itsString.str().length();
|
||||||
@@ -121,12 +121,12 @@ template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Format &f)
|
template <typename C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const Format &f)
|
||||||
{
|
{
|
||||||
return operator<<(Color(f));
|
return operator<<(Color(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const NCurses::basic_buffer<C> &buf)
|
template <typename C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<<(const NCurses::basic_buffer<C> &buf)
|
||||||
{
|
{
|
||||||
size_t len = itsString.str().length();
|
size_t len = itsString.str().length();
|
||||||
itsString << buf.itsString.str();
|
itsString << buf.itsString.str();
|
||||||
@@ -138,7 +138,7 @@ template <class C> NCurses::basic_buffer<C> &NCurses::basic_buffer<C>::operator<
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C> NCurses::Window &operator<<(NCurses::Window &w, const NCurses::basic_buffer<C> &buf)
|
template <typename C> NCurses::Window &operator<<(NCurses::Window &w, const NCurses::basic_buffer<C> &buf)
|
||||||
{
|
{
|
||||||
const std::basic_string<C> &s = buf.itsTempString ? *buf.itsTempString : buf.itsString.str();
|
const std::basic_string<C> &s = buf.itsTempString ? *buf.itsTempString : buf.itsString.str();
|
||||||
if (buf.itsFormat.empty())
|
if (buf.itsFormat.empty())
|
||||||
|
|||||||
Reference in New Issue
Block a user