SerialConnect: add a clear/reset menu.
Change-Id: I0435ba679e19094d201d65ac0c6290cd194ec344 Reviewed-on: https://review.haiku-os.org/c/1463 Reviewed-by: waddlesplash <[email protected]>
This commit is contained in:
committed by
waddlesplash
parent
506f9764d4
commit
1eb386084c
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017, Adrien Destugues, pulkomandy@gmail.com
|
||||
* Copyright 2012-2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
||||
* Distributed under the terms of the MIT licence.
|
||||
*/
|
||||
|
||||
@@ -65,6 +65,7 @@ enum messageConstants {
|
||||
kMsgProgress = 'prog',
|
||||
kMsgSettings = 'stty',
|
||||
kMsgSendFile = 'sndf',
|
||||
kMsgClear = 'cler',
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2017, Adrien Destugues, [email protected]
|
||||
* Copyright 2012-2019, Adrien Destugues, [email protected]
|
||||
* Distributed under the terms of the MIT licence.
|
||||
*/
|
||||
|
||||
@@ -58,6 +58,7 @@ SerialWindow::SerialWindow()
|
||||
r.right = r.left + B_V_SCROLL_BAR_WIDTH;
|
||||
r.top -= 1;
|
||||
r.bottom -= B_H_SCROLL_BAR_HEIGHT - 1;
|
||||
|
||||
BScrollBar* scrollBar = new BScrollBar(r, "scrollbar", NULL, 0, 0,
|
||||
B_VERTICAL);
|
||||
|
||||
@@ -81,18 +82,15 @@ SerialWindow::SerialWindow()
|
||||
fConnectionMenu = new BMenu("Connection");
|
||||
fFileMenu = new BMenu("File");
|
||||
BMenu* settingsMenu = new BMenu("Settings");
|
||||
BMenu* editMenu = new BMenu("Edit");
|
||||
|
||||
fConnectionMenu->SetRadioMode(true);
|
||||
|
||||
menuBar->AddItem(fConnectionMenu);
|
||||
menuBar->AddItem(editMenu);
|
||||
menuBar->AddItem(fFileMenu);
|
||||
menuBar->AddItem(settingsMenu);
|
||||
|
||||
// TODO edit menu - what's in it ? Usual copy/paste would be nice but we
|
||||
// need a way to select text in the window.
|
||||
//BMenu* editMenu = new BMenu("Edit");
|
||||
//menuBar->AddItem(editMenu);
|
||||
|
||||
BMenuItem* logFile = new BMenuItem("Log to file" B_UTF8_ELLIPSIS,
|
||||
new BMessage(kMsgLogfile));
|
||||
fFileMenu->AddItem(logFile);
|
||||
@@ -119,6 +117,13 @@ SerialWindow::SerialWindow()
|
||||
xmodemReceive->SetEnabled(false);
|
||||
#endif
|
||||
|
||||
// Items for the edit menu
|
||||
BMenuItem* clearScreen = new BMenuItem("Clear history",
|
||||
new BMessage(kMsgClear));
|
||||
editMenu->AddItem(clearScreen);
|
||||
|
||||
// TODO copy (when we have selection), paste
|
||||
|
||||
// Configuring all this by menus may be a bit unhandy. Make a setting
|
||||
// window instead ?
|
||||
fBaudrateMenu = new BMenu("Baud rate");
|
||||
@@ -440,6 +445,11 @@ void SerialWindow::MessageReceived(BMessage* message)
|
||||
|
||||
return;
|
||||
}
|
||||
case kMsgClear:
|
||||
{
|
||||
fTermView->Clear();
|
||||
return;
|
||||
}
|
||||
case kMsgProgress:
|
||||
{
|
||||
// File transfer progress
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015, Adrien Destugues, pulkomandy@gmail.com
|
||||
* Copyright 2012-2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
||||
* Distributed under the terms of the MIT licence.
|
||||
*/
|
||||
|
||||
@@ -266,6 +266,20 @@ TermView::PushBytes(const char* bytes, size_t length)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::Clear()
|
||||
{
|
||||
while(fScrollBuffer.ItemAt(0)) {
|
||||
free(fScrollBuffer.RemoveItem(0l));
|
||||
}
|
||||
|
||||
vterm_state_reset(vterm_obtain_state(fTerm), 1);
|
||||
vterm_screen_reset(fTermScreen, 1);
|
||||
|
||||
_UpdateScrollbar();
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
@@ -437,6 +451,13 @@ TermView::_PushLine(int cols, const VTermScreenCell* cells)
|
||||
|
||||
free(fScrollBuffer.RemoveItem(kScrollBackSize));
|
||||
|
||||
_UpdateScrollbar();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
TermView::_UpdateScrollbar()
|
||||
{
|
||||
int availableRows, availableCols;
|
||||
vterm_get_size(fTerm, &availableRows, &availableCols);
|
||||
|
||||
@@ -462,6 +483,14 @@ TermView::_PushLine(int cols, const VTermScreenCell* cells)
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
TermView::_PopLine(int cols, VTermScreenCell* cells)
|
||||
{
|
||||
/* TODO can be used when switching to alt screen and when resizing */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* static */ int
|
||||
TermView::_Damage(VTermRect rect, void* user)
|
||||
{
|
||||
@@ -492,6 +521,14 @@ TermView::_PushLine(int cols, const VTermScreenCell* cells, void* user)
|
||||
}
|
||||
|
||||
|
||||
/* static */ int
|
||||
TermView::_PopLine(int cols, VTermScreenCell* cells, void* user)
|
||||
{
|
||||
TermView* view = (TermView*)user;
|
||||
return view->_PopLine(cols, cells);
|
||||
}
|
||||
|
||||
|
||||
const
|
||||
VTermScreenCallbacks TermView::sScreenCallbacks = {
|
||||
&TermView::_Damage,
|
||||
@@ -502,5 +539,5 @@ VTermScreenCallbacks TermView::sScreenCallbacks = {
|
||||
/*.bell =*/ NULL,
|
||||
/*.resize =*/ NULL,
|
||||
&TermView::_PushLine,
|
||||
/*.sb_popline =*/ NULL,
|
||||
&TermView::_PopLine,
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2015, Adrien Destugues, pulkomandy@gmail.com
|
||||
* Copyright 2012-2019, Adrien Destugues, pulkomandy@pulkomandy.tk
|
||||
* Distributed under the terms of the MIT licence.
|
||||
*/
|
||||
|
||||
@@ -28,6 +28,7 @@ class TermView: public BView
|
||||
void SetLineTerminator(BString bytes);
|
||||
|
||||
void PushBytes(const char* bytes, const size_t length);
|
||||
void Clear();
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
@@ -42,13 +43,15 @@ class TermView: public BView
|
||||
void _MoveCursor(VTermPos pos, VTermPos oldPos,
|
||||
int visible);
|
||||
void _PushLine(int cols, const VTermScreenCell* cells);
|
||||
int _PopLine(int cols, VTermScreenCell* cells);
|
||||
void _UpdateScrollbar();
|
||||
|
||||
static int _Damage(VTermRect rect, void* user);
|
||||
static int _MoveCursor(VTermPos pos, VTermPos oldPos,
|
||||
int visible, void* user);
|
||||
static int _PushLine(int cols, const VTermScreenCell* cells,
|
||||
void* user);
|
||||
static int _PopLine(int cols, const VTermScreenCell* cells,
|
||||
static int _PopLine(int cols, VTermScreenCell* cells,
|
||||
void* user);
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user