diff --git a/src/apps/serialconnect/TermView.cpp b/src/apps/serialconnect/TermView.cpp index cb655251ea..d977222576 100644 --- a/src/apps/serialconnect/TermView.cpp +++ b/src/apps/serialconnect/TermView.cpp @@ -15,7 +15,7 @@ TermView::TermView() : - BView("TermView", B_WILL_DRAW) + BView("TermView", B_WILL_DRAW | B_FRAME_EVENTS) { font_height height; GetFontHeight(&height); @@ -52,6 +52,10 @@ void TermView::Draw(BRect updateRect) VTermPos pos; font_height height; GetFontHeight(&height); + + int availableRows, availableCols; + vterm_get_size(fTerm, &availableRows, &availableCols); + for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row; pos.row++) { float x = updatedChars.start_col * fFontWidth + kBorderSpacing; @@ -60,8 +64,8 @@ void TermView::Draw(BRect updateRect) for (pos.col = updatedChars.start_col; pos.col <= updatedChars.end_col;) { - if (pos.col < 0 || pos.row < 0 || pos.col >= kDefaultWidth - || pos.row >= kDefaultHeight) { + if (pos.col < 0 || pos.row < 0 || pos.col >= availableCols + || pos.row >= availableRows) { DrawString(" "); pos.col ++; } else { @@ -102,6 +106,14 @@ void TermView::KeyDown(const char* bytes, int32 numBytes) } +void TermView::FrameResized(float width, float height) +{ + VTermRect newSize = PixelsToGlyphs(BRect(0, 0, width - 2 * kBorderSpacing, + height - 2 * kBorderSpacing)); + vterm_set_size(fTerm, newSize.end_row, newSize.end_col); +} + + void TermView::PushBytes(const char* bytes, size_t length) { vterm_push_bytes(fTerm, bytes, length); diff --git a/src/apps/serialconnect/TermView.h b/src/apps/serialconnect/TermView.h index 985863d19e..50c8c7e63d 100644 --- a/src/apps/serialconnect/TermView.h +++ b/src/apps/serialconnect/TermView.h @@ -20,6 +20,7 @@ class TermView: public BView void Draw(BRect updateRect); void GetPreferredSize(float* width, float* height); void KeyDown(const char* bytes, int32 numBytes); + void FrameResized(float width, float height); void PushBytes(const char* bytes, const size_t length); private: