Resize terminal buffer with window.
Unlike in Haiku terminal, vterm does not rearrange lines wen they are wrapped. Chars outside the viewing area are just lost.
This commit is contained in:
parent
469e6cd228
commit
7e23386ae8
@ -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);
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user