Terminal: match declarations and definitions

Change-Id: Ib05915bedca38a0f3caec80d96c643200b1bc4a9
Reviewed-on: https://review.haiku-os.org/c/haiku/+/2111
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
Zotyamester
2020-01-22 00:30:40 +00:00
committed by waddlesplash
parent 1773f0767e
commit 093e83638d
3 changed files with 71 additions and 69 deletions
+64 -63
View File
@@ -1521,71 +1521,71 @@ TermView::FrameResized(float width, float height)
void void
TermView::MessageReceived(BMessage *msg) TermView::MessageReceived(BMessage *message)
{ {
if (fActiveState->MessageReceived(msg)) if (fActiveState->MessageReceived(message))
return; return;
entry_ref ref; entry_ref ref;
const char *ctrl_l = "\x0c"; const char *ctrl_l = "\x0c";
// first check for any dropped message // first check for any dropped message
if (msg->WasDropped() && (msg->what == B_SIMPLE_DATA if (message->WasDropped() && (message->what == B_SIMPLE_DATA
|| msg->what == B_MIME_DATA)) { || message->what == B_MIME_DATA)) {
char *text; char *text;
ssize_t numBytes; ssize_t numBytes;
//rgb_color *color; //rgb_color *color;
int32 i = 0; int32 i = 0;
if (msg->FindRef("refs", i++, &ref) == B_OK) { if (message->FindRef("refs", i++, &ref) == B_OK) {
// first check if secondary mouse button is pressed // first check if secondary mouse button is pressed
int32 buttons = 0; int32 buttons = 0;
msg->FindInt32("buttons", &buttons); message->FindInt32("buttons", &buttons);
if (buttons == B_SECONDARY_MOUSE_BUTTON) { if (buttons == B_SECONDARY_MOUSE_BUTTON) {
// start popup menu // start popup menu
_SecondaryMouseButtonDropped(msg); _SecondaryMouseButtonDropped(message);
return; return;
} }
_DoFileDrop(ref); _DoFileDrop(ref);
while (msg->FindRef("refs", i++, &ref) == B_OK) { while (message->FindRef("refs", i++, &ref) == B_OK) {
_WritePTY(" ", 1); _WritePTY(" ", 1);
_DoFileDrop(ref); _DoFileDrop(ref);
} }
return; return;
#if 0 #if 0
} else if (msg->FindData("RGBColor", B_RGB_COLOR_TYPE, } else if (message->FindData("RGBColor", B_RGB_COLOR_TYPE,
(const void **)&color, &numBytes) == B_OK (const void **)&color, &numBytes) == B_OK
&& numBytes == sizeof(color)) { && numBytes == sizeof(color)) {
// TODO: handle color drop // TODO: handle color drop
// maybe only on replicants ? // maybe only on replicants ?
return; return;
#endif #endif
} else if (msg->FindData("text/plain", B_MIME_TYPE, } else if (message->FindData("text/plain", B_MIME_TYPE,
(const void **)&text, &numBytes) == B_OK) { (const void **)&text, &numBytes) == B_OK) {
_WritePTY(text, numBytes); _WritePTY(text, numBytes);
return; return;
} }
} }
switch (msg->what) { switch (message->what) {
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
{ {
// handle refs if they weren't dropped // handle refs if they weren't dropped
int32 i = 0; int32 i = 0;
if (msg->FindRef("refs", i++, &ref) == B_OK) { if (message->FindRef("refs", i++, &ref) == B_OK) {
_DoFileDrop(ref); _DoFileDrop(ref);
while (msg->FindRef("refs", i++, &ref) == B_OK) { while (message->FindRef("refs", i++, &ref) == B_OK) {
_WritePTY(" ", 1); _WritePTY(" ", 1);
_DoFileDrop(ref); _DoFileDrop(ref);
} }
} else } else
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
@@ -1596,7 +1596,7 @@ TermView::MessageReceived(BMessage *msg)
case B_PASTE: case B_PASTE:
{ {
int32 code; int32 code;
if (msg->FindInt32("index", &code) == B_OK) if (message->FindInt32("index", &code) == B_OK)
Paste(be_clipboard); Paste(be_clipboard);
break; break;
} }
@@ -1633,14 +1633,14 @@ TermView::MessageReceived(BMessage *msg)
int32 i; int32 i;
int32 encodingID; int32 encodingID;
BMessage specifier; BMessage specifier;
if (msg->GetCurrentSpecifier(&i, &specifier) == B_OK if (message->GetCurrentSpecifier(&i, &specifier) == B_OK
&& strcmp("encoding", && strcmp("encoding",
specifier.FindString("property", i)) == 0) { specifier.FindString("property", i)) == 0) {
msg->FindInt32 ("data", &encodingID); message->FindInt32 ("data", &encodingID);
SetEncoding(encodingID); SetEncoding(encodingID);
msg->SendReply(B_REPLY); message->SendReply(B_REPLY);
} else { } else {
BView::MessageReceived(msg); BView::MessageReceived(message);
} }
break; break;
} }
@@ -1649,21 +1649,21 @@ TermView::MessageReceived(BMessage *msg)
{ {
int32 i; int32 i;
BMessage specifier; BMessage specifier;
if (msg->GetCurrentSpecifier(&i, &specifier) == B_OK) { if (message->GetCurrentSpecifier(&i, &specifier) == B_OK) {
if (strcmp("encoding", if (strcmp("encoding",
specifier.FindString("property", i)) == 0) { specifier.FindString("property", i)) == 0) {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
reply.AddInt32("result", Encoding()); reply.AddInt32("result", Encoding());
msg->SendReply(&reply); message->SendReply(&reply);
} else if (strcmp("tty", } else if (strcmp("tty",
specifier.FindString("property", i)) == 0) { specifier.FindString("property", i)) == 0) {
BMessage reply(B_REPLY); BMessage reply(B_REPLY);
reply.AddString("result", TerminalName()); reply.AddString("result", TerminalName());
msg->SendReply(&reply); message->SendReply(&reply);
} else } else
BView::MessageReceived(msg); BView::MessageReceived(message);
} else } else
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
@@ -1676,12 +1676,12 @@ TermView::MessageReceived(BMessage *msg)
case B_INPUT_METHOD_EVENT: case B_INPUT_METHOD_EVENT:
{ {
int32 opcode; int32 opcode;
if (msg->FindInt32("be:opcode", &opcode) == B_OK) { if (message->FindInt32("be:opcode", &opcode) == B_OK) {
switch (opcode) { switch (opcode) {
case B_INPUT_METHOD_STARTED: case B_INPUT_METHOD_STARTED:
{ {
BMessenger messenger; BMessenger messenger;
if (msg->FindMessenger("be:reply_to", if (message->FindMessenger("be:reply_to",
&messenger) == B_OK) { &messenger) == B_OK) {
fInline = new (std::nothrow) fInline = new (std::nothrow)
InlineInput(messenger); InlineInput(messenger);
@@ -1696,7 +1696,7 @@ TermView::MessageReceived(BMessage *msg)
case B_INPUT_METHOD_CHANGED: case B_INPUT_METHOD_CHANGED:
if (fInline != NULL) if (fInline != NULL)
_HandleInputMethodChanged(msg); _HandleInputMethodChanged(message);
break; break;
case B_INPUT_METHOD_LOCATION_REQUEST: case B_INPUT_METHOD_LOCATION_REQUEST:
@@ -1718,7 +1718,7 @@ TermView::MessageReceived(BMessage *msg)
BAutolock locker(fTextBuffer); BAutolock locker(fTextBuffer);
float deltaY = 0; float deltaY = 0;
if (fTextBuffer->IsAlternateScreenActive() if (fTextBuffer->IsAlternateScreenActive()
&& msg->FindFloat("be:wheel_delta_y", &deltaY) == B_OK && message->FindFloat("be:wheel_delta_y", &deltaY) == B_OK
&& deltaY != 0) { && deltaY != 0) {
// We are in alternative screen mode and have a vertical delta // We are in alternative screen mode and have a vertical delta
// we can work with -- emulate scrolling via terminal escape // we can work with -- emulate scrolling via terminal escape
@@ -1751,7 +1751,7 @@ TermView::MessageReceived(BMessage *msg)
} else { } else {
// let the BView's implementation handle the standard scrolling // let the BView's implementation handle the standard scrolling
locker.Unlock(); locker.Unlock();
BView::MessageReceived(msg); BView::MessageReceived(message);
} }
break; break;
@@ -1768,7 +1768,7 @@ TermView::MessageReceived(BMessage *msg)
_UpdateSIGWINCH(); _UpdateSIGWINCH();
break; break;
case kSecondaryMouseDropAction: case kSecondaryMouseDropAction:
_DoSecondaryMouseDropAction(msg); _DoSecondaryMouseDropAction(message);
break; break;
case MSG_TERMINAL_BUFFER_CHANGED: case MSG_TERMINAL_BUFFER_CHANGED:
{ {
@@ -1779,7 +1779,7 @@ TermView::MessageReceived(BMessage *msg)
case MSG_SET_TERMINAL_TITLE: case MSG_SET_TERMINAL_TITLE:
{ {
const char* title; const char* title;
if (msg->FindString("title", &title) == B_OK) { if (message->FindString("title", &title) == B_OK) {
if (fListener != NULL) if (fListener != NULL)
fListener->SetTermViewTitle(this, title); fListener->SetTermViewTitle(this, title);
} }
@@ -1788,19 +1788,19 @@ TermView::MessageReceived(BMessage *msg)
case MSG_SET_TERMINAL_COLORS: case MSG_SET_TERMINAL_COLORS:
{ {
int32 count = 0; int32 count = 0;
if (msg->FindInt32("count", &count) != B_OK) if (message->FindInt32("count", &count) != B_OK)
break; break;
bool dynamic = false; bool dynamic = false;
if (msg->FindBool("dynamic", &dynamic) != B_OK) if (message->FindBool("dynamic", &dynamic) != B_OK)
break; break;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
uint8 index = 0; uint8 index = 0;
if (msg->FindUInt8("index", i, &index) != B_OK) if (message->FindUInt8("index", i, &index) != B_OK)
break; break;
ssize_t bytes = 0; ssize_t bytes = 0;
rgb_color* color = 0; rgb_color* color = 0;
if (msg->FindData("color", B_RGB_COLOR_TYPE, if (message->FindData("color", B_RGB_COLOR_TYPE,
i, (const void**)&color, &bytes) != B_OK) i, (const void**)&color, &bytes) != B_OK)
break; break;
SetTermColor(index, *color, dynamic); SetTermColor(index, *color, dynamic);
@@ -1810,14 +1810,14 @@ TermView::MessageReceived(BMessage *msg)
case MSG_RESET_TERMINAL_COLORS: case MSG_RESET_TERMINAL_COLORS:
{ {
int32 count = 0; int32 count = 0;
if (msg->FindInt32("count", &count) != B_OK) if (message->FindInt32("count", &count) != B_OK)
break; break;
bool dynamic = false; bool dynamic = false;
if (msg->FindBool("dynamic", &dynamic) != B_OK) if (message->FindBool("dynamic", &dynamic) != B_OK)
break; break;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
uint8 index = 0; uint8 index = 0;
if (msg->FindUInt8("index", i, &index) != B_OK) if (message->FindUInt8("index", i, &index) != B_OK)
break; break;
SetTermColor(index, SetTermColor(index,
@@ -1828,44 +1828,45 @@ TermView::MessageReceived(BMessage *msg)
case MSG_SET_CURSOR_STYLE: case MSG_SET_CURSOR_STYLE:
{ {
int32 style = BLOCK_CURSOR; int32 style = BLOCK_CURSOR;
if (msg->FindInt32("style", &style) == B_OK) if (message->FindInt32("style", &style) == B_OK)
fCursorStyle = style; fCursorStyle = style;
bool blinking = fCursorBlinking; bool blinking = fCursorBlinking;
if (msg->FindBool("blinking", &blinking) == B_OK) if (message->FindBool("blinking", &blinking) == B_OK)
SwitchCursorBlinking(blinking); SwitchCursorBlinking(blinking);
bool hidden = fCursorHidden; bool hidden = fCursorHidden;
if (msg->FindBool("hidden", &hidden) == B_OK) if (message->FindBool("hidden", &hidden) == B_OK)
fCursorHidden = hidden; fCursorHidden = hidden;
break; break;
} }
case MSG_ENABLE_META_KEY: case MSG_ENABLE_META_KEY:
{ {
bool enable; bool enable;
if (msg->FindBool("enableInterpretMetaKey", &enable) == B_OK) if (message->FindBool("enableInterpretMetaKey", &enable) == B_OK)
fInterpretMetaKey = enable; fInterpretMetaKey = enable;
if (msg->FindBool("enableMetaKeySendsEscape", &enable) == B_OK) if (message->FindBool("enableMetaKeySendsEscape", &enable) == B_OK)
fMetaKeySendsEscape = enable; fMetaKeySendsEscape = enable;
break; break;
} }
case MSG_REPORT_MOUSE_EVENT: case MSG_REPORT_MOUSE_EVENT:
{ {
bool value; bool value;
if (msg->FindBool("reportX10MouseEvent", &value) == B_OK) if (message->FindBool("reportX10MouseEvent", &value) == B_OK)
fReportX10MouseEvent = value; fReportX10MouseEvent = value;
if (msg->FindBool("reportNormalMouseEvent", &value) == B_OK) if (message->FindBool("reportNormalMouseEvent", &value) == B_OK)
fReportNormalMouseEvent = value; fReportNormalMouseEvent = value;
if (msg->FindBool("reportButtonMouseEvent", &value) == B_OK) if (message->FindBool("reportButtonMouseEvent", &value) == B_OK)
fReportButtonMouseEvent = value; fReportButtonMouseEvent = value;
if (msg->FindBool("reportAnyMouseEvent", &value) == B_OK) if (message->FindBool("reportAnyMouseEvent", &value) == B_OK)
fReportAnyMouseEvent = value; fReportAnyMouseEvent = value;
if (msg->FindBool("enableExtendedMouseCoordinates", &value) == B_OK) if (message->FindBool(
"enableExtendedMouseCoordinates", &value) == B_OK)
fEnableExtendedMouseCoordinates = value; fEnableExtendedMouseCoordinates = value;
break; break;
} }
@@ -1890,21 +1891,21 @@ TermView::MessageReceived(BMessage *msg)
case MSG_QUIT_TERMNAL: case MSG_QUIT_TERMNAL:
{ {
int32 reason; int32 reason;
if (msg->FindInt32("reason", &reason) != B_OK) if (message->FindInt32("reason", &reason) != B_OK)
reason = 0; reason = 0;
if (fListener != NULL) if (fListener != NULL)
fListener->NotifyTermViewQuit(this, reason); fListener->NotifyTermViewQuit(this, reason);
break; break;
} }
default: default:
BView::MessageReceived(msg); BView::MessageReceived(message);
break; break;
} }
} }
status_t status_t
TermView::GetSupportedSuites(BMessage *message) TermView::GetSupportedSuites(BMessage* message)
{ {
BPropertyInfo propInfo(sPropList); BPropertyInfo propInfo(sPropList);
message->AddString("suites", "suite/vnd.naan-termview"); message->AddString("suites", "suite/vnd.naan-termview");
@@ -1981,30 +1982,30 @@ TermView::ResolveSpecifier(BMessage* message, int32 index, BMessage* specifier,
void void
TermView::_SecondaryMouseButtonDropped(BMessage* msg) TermView::_SecondaryMouseButtonDropped(BMessage* message)
{ {
// Launch menu to choose what is to do with the msg data // Launch menu to choose what is to do with the message data
BPoint point; BPoint point;
if (msg->FindPoint("_drop_point_", &point) != B_OK) if (message->FindPoint("_drop_point_", &point) != B_OK)
return; return;
BMessage* insertMessage = new BMessage(*msg); BMessage* insertMessage = new BMessage(*message);
insertMessage->what = kSecondaryMouseDropAction; insertMessage->what = kSecondaryMouseDropAction;
insertMessage->AddInt8("action", kInsert); insertMessage->AddInt8("action", kInsert);
BMessage* cdMessage = new BMessage(*msg); BMessage* cdMessage = new BMessage(*message);
cdMessage->what = kSecondaryMouseDropAction; cdMessage->what = kSecondaryMouseDropAction;
cdMessage->AddInt8("action", kChangeDirectory); cdMessage->AddInt8("action", kChangeDirectory);
BMessage* lnMessage = new BMessage(*msg); BMessage* lnMessage = new BMessage(*message);
lnMessage->what = kSecondaryMouseDropAction; lnMessage->what = kSecondaryMouseDropAction;
lnMessage->AddInt8("action", kLinkFiles); lnMessage->AddInt8("action", kLinkFiles);
BMessage* mvMessage = new BMessage(*msg); BMessage* mvMessage = new BMessage(*message);
mvMessage->what = kSecondaryMouseDropAction; mvMessage->what = kSecondaryMouseDropAction;
mvMessage->AddInt8("action", kMoveFiles); mvMessage->AddInt8("action", kMoveFiles);
BMessage* cpMessage = new BMessage(*msg); BMessage* cpMessage = new BMessage(*message);
cpMessage->what = kSecondaryMouseDropAction; cpMessage->what = kSecondaryMouseDropAction;
cpMessage->AddInt8("action", kCopyFiles); cpMessage->AddInt8("action", kCopyFiles);
@@ -2023,7 +2024,7 @@ TermView::_SecondaryMouseButtonDropped(BMessage* msg)
BDirectory firstDir; BDirectory firstDir;
entry_ref ref; entry_ref ref;
int i = 0; int i = 0;
while (msg->FindRef("refs", i++, &ref) == B_OK) { while (message->FindRef("refs", i++, &ref) == B_OK) {
BNode node(&ref); BNode node(&ref);
BEntry entry(&ref); BEntry entry(&ref);
BDirectory dir; BDirectory dir;
@@ -2061,10 +2062,10 @@ TermView::_SecondaryMouseButtonDropped(BMessage* msg)
void void
TermView::_DoSecondaryMouseDropAction(BMessage* msg) TermView::_DoSecondaryMouseDropAction(BMessage* message)
{ {
int8 action = -1; int8 action = -1;
msg->FindInt8("action", &action); message->FindInt8("action", &action);
BString outString = ""; BString outString = "";
BString itemString = ""; BString itemString = "";
@@ -2092,7 +2093,7 @@ TermView::_DoSecondaryMouseDropAction(BMessage* msg)
bool listContainsDirectory = false; bool listContainsDirectory = false;
entry_ref ref; entry_ref ref;
int32 i = 0; int32 i = 0;
while (msg->FindRef("refs", i++, &ref) == B_OK) { while (message->FindRef("refs", i++, &ref) == B_OK) {
BEntry ent(&ref); BEntry ent(&ref);
BNode node(&ref); BNode node(&ref);
BPath path(&ent); BPath path(&ent);
+5 -5
View File
@@ -82,7 +82,7 @@ public:
void GetFontSize(float* width, float* height); void GetFontSize(float* width, float* height);
int Rows() const; int Rows() const;
int Columns() const; int Columns() const;
BRect SetTermSize(int rows, int cols, BRect SetTermSize(int rows, int columns,
bool notifyShell); bool notifyShell);
void SetTermSize(BRect rect, void SetTermSize(BRect rect,
bool notifyShell = false); bool notifyShell = false);
@@ -152,8 +152,8 @@ protected:
virtual void ScrollTo(BPoint where); virtual void ScrollTo(BPoint where);
virtual void TargetedByScrollView(BScrollView *scrollView); virtual void TargetedByScrollView(BScrollView *scrollView);
virtual status_t GetSupportedSuites(BMessage* msg); virtual status_t GetSupportedSuites(BMessage* message);
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index, virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form, BMessage* specifier, int32 form,
const char* property); const char* property);
@@ -215,8 +215,8 @@ private:
void _DoPrint(BRect updateRect); void _DoPrint(BRect updateRect);
void _UpdateScrollBarRange(); void _UpdateScrollBarRange();
void _SecondaryMouseButtonDropped(BMessage* msg); void _SecondaryMouseButtonDropped(BMessage* message);
void _DoSecondaryMouseDropAction(BMessage* msg); void _DoSecondaryMouseDropAction(BMessage* message);
void _DoFileDrop(entry_ref &ref); void _DoFileDrop(entry_ref &ref);
void _SynchronizeWithTextBuffer( void _SynchronizeWithTextBuffer(
+2 -1
View File
@@ -135,7 +135,8 @@ private:
struct Session; struct Session;
private: private:
void _SetTermColors(TermViewContainerView* termView); void _SetTermColors(
TermViewContainerView* containerView);
void _InitWindow(); void _InitWindow();
void _SetupMenu(); void _SetupMenu();
static BMenu* _MakeFontSizeMenu(uint32 command, static BMenu* _MakeFontSizeMenu(uint32 command,