Skip to content

Commit

Permalink
Update in line with Platform.h modernization.
Browse files Browse the repository at this point in the history
  • Loading branch information
orbitalquark committed May 25, 2018
1 parent aeb633b commit 0de4e47
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions ScintillaCurses.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ using namespace Scintilla;
* done in `Font::Create()`.
* @see Font::Create
*/
Font::Font() : fid(0) {}
Font::Font() noexcept : fid(0) {}
/** Deletes the font. Currently empty. */
Font::~Font() {}
/**
Expand Down Expand Up @@ -279,7 +279,8 @@ class SurfaceImpl : public Surface {
* Line markers that Scintilla would normally draw as polygons are handled in
* `DrawLineMarker()`.
*/
void Polygon(Point *pts, int npts, ColourDesired fore, ColourDesired back) {
void Polygon(Point *pts, size_t npts, ColourDesired fore,
ColourDesired back) {
wattr_set(win, 0, term_color_pair(back, COLOR_WHITE), NULL); // invert
if (pts[0].y < pts[npts - 1].y) // up arrow
mvwaddstr(win, pts[0].y, pts[npts - 1].x + 1, "");
Expand Down Expand Up @@ -447,8 +448,6 @@ class SurfaceImpl : public Surface {
if (!UTF8IsTrailByte((unsigned char)s[i])) width += grapheme_width(s + i);
return width;
}
/** Returns 1 since curses characters always have a width of 1. */
XYPOSITION WidthChar(Font &font_, char ch) { return 1; }
/** Returns 0 since curses characters have no ascent. */
XYPOSITION Ascent(Font &font_) { return 0; }
/** Returns 0 since curses characters have no descent. */
Expand Down Expand Up @@ -620,7 +619,7 @@ void Window::Destroy() {
* bounds to ensure all of it is painted.
* @return PRectangle with the window's boundaries.
*/
PRectangle Window::GetPosition() {
PRectangle Window::GetPosition() const {
int maxx = wid ? getmaxx(_WINDOW(wid)) : 0;
int maxy = wid ? getmaxy(_WINDOW(wid)) : 0;
return PRectangle(0, 0, maxx, maxy);
Expand All @@ -631,19 +630,19 @@ PRectangle Window::GetPosition() {
* @param rc The position relative to the parent window.
* @param relativeTo The parent window.
*/
void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
void Window::SetPositionRelative(PRectangle rc, const Window *relativeTo) {
int begx = 0, begy = 0, x = 0, y = 0;
// Determine the relative position.
getbegyx(_WINDOW(relativeTo.GetID()), begy, begx);
getbegyx(_WINDOW(relativeTo->GetID()), begy, begx);
x = begx + rc.left;
if (x < begx) x = begx;
y = begy + rc.top;
if (y < begy) y = begy;
// Correct to fit the parent if necessary.
int sizex = rc.right - rc.left;
int sizey = rc.bottom - rc.top;
int screen_width = getmaxx(_WINDOW(relativeTo.GetID()));
int screen_height = getmaxy(_WINDOW(relativeTo.GetID()));
int screen_width = getmaxx(_WINDOW(relativeTo->GetID()));
int screen_height = getmaxy(_WINDOW(relativeTo->GetID()));
if (sizex > screen_width)
x = begx; // align left
else if (x + sizex > begx + screen_width)
Expand All @@ -657,7 +656,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
mvwin(_WINDOW(wid), y, x);
}
/** Identical to `Window::GetPosition()`. */
PRectangle Window::GetClientPosition() { return GetPosition(); }
PRectangle Window::GetClientPosition() const { return GetPosition(); }
void Window::Show(bool show) { /* TODO: */ }
void Window::InvalidateAll() { /* notify repaint */ }
void Window::InvalidateRectangle(PRectangle rc) { /* notify repaint*/ }
Expand Down Expand Up @@ -840,14 +839,14 @@ class ListBoxImpl : public ListBox {
};

/** Creates a new Scintilla ListBox. */
ListBox::ListBox() {}
ListBox::ListBox() noexcept {}
/** Deletes the ListBox. */
ListBox::~ListBox() {}
/** Creates a new curses ListBox. */
ListBox *ListBox::Allocate() { return new ListBoxImpl(); }

// Menus are not implemented.
Menu::Menu() : mid(0) {}
Menu::Menu() noexcept : mid(0) {}
void Menu::CreatePopUp() {}
void Menu::Destroy() {}
void Menu::Show(Point pt, Window &w) {}
Expand Down

0 comments on commit 0de4e47

Please sign in to comment.