Style fixes in a couple functions -- need to fix the entire app, but not right now

Dropping multiple files in the terminal now prints all files' paths instead of just one


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13504 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
DarkWyrm
2005-07-06 17:59:53 +00:00
parent fa65b351ea
commit 94935cfc3c
+36 -24
View File
@@ -1821,56 +1821,69 @@ TermView::MessageReceived(BMessage *msg)
switch(msg->what){ switch(msg->what){
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
if (msg->FindRef("refs", &ref) == B_OK ){ {
int32 i=0;
if(msg->FindRef("refs", i++, &ref) == B_OK)
{
this->DoFileDrop(ref); this->DoFileDrop(ref);
} else {
while(msg->FindRef("refs", i++, &ref) == B_OK)
this->DoFileDrop(ref);
}
else
{
BView::MessageReceived(msg); BView::MessageReceived(msg);
} }
break; break;
}
case B_MIME_DATA: case B_MIME_DATA:
{
char *text; char *text;
int32 num_bytes; int32 num_bytes;
status_t sts; status_t sts;
if (msg->WasDropped()){ if (msg->WasDropped())
{
sts = msg->FindData ((const char *)"text/plain", sts = msg->FindData ((const char *)"text/plain",
(type_code)B_MIME_TYPE, (type_code)B_MIME_TYPE,
(const void **)&text, (const void **)&text, &num_bytes);
&num_bytes); if (sts != B_OK)
break;
if (sts != B_OK) break; // Clipboard text doesn't attached EOF?
/* Clipboard text doesn't attached EOF? */
text[num_bytes] = '\0'; text[num_bytes] = '\0';
WritePTY ((uchar *)text, num_bytes); WritePTY ((uchar *)text, num_bytes);
} }
break; break;
}
case B_COPY: case B_COPY:
{
this->DoCopy(); this->DoCopy();
break; break;
}
case B_PASTE: case B_PASTE:
{
int32 code; int32 code;
if (msg->FindInt32 ("index", &code) == B_OK) if (msg->FindInt32 ("index", &code) == B_OK)
this->DoPaste(); this->DoPaste();
break; break;
}
case B_SELECT_ALL: case B_SELECT_ALL:
{
this->DoSelectAll(); this->DoSelectAll();
break; break;
}
case MENU_CLEAR_ALL: case MENU_CLEAR_ALL:
{
this->DoClearAll(); this->DoClearAll();
write (pfd, ctrl_l, 1); write (pfd, ctrl_l, 1);
break; break;
}
case MSGRUN_CURSOR: case MSGRUN_CURSOR:
this->BlinkCursor (); {
this->BlinkCursor();
break; break;
}
// case B_INPUT_METHOD_EVENT: // case B_INPUT_METHOD_EVENT:
// { // {
@@ -1894,11 +1907,12 @@ TermView::MessageReceived(BMessage *msg)
// break; // break;
// } // }
// } // }
default: default:
{
BView::MessageReceived(msg); BView::MessageReceived(msg);
break; break;
} }
}
} }
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
// DoFileDrop // DoFileDrop
@@ -1907,14 +1921,13 @@ TermView::MessageReceived(BMessage *msg)
void void
TermView::DoFileDrop(entry_ref &ref) TermView::DoFileDrop(entry_ref &ref)
{ {
char p[B_PATH_NAME_LENGTH * 2 + 1];
BEntry ent(&ref); BEntry ent(&ref);
BPath path(&ent); BPath path(&ent);
BString string(path.Path());
int num_bytes = SubstMetaChar (path.Path(), p); string.CharacterEscape(" ~`#$&*()\\|[]{};'\"<>?!",'\\');
string+=" ";
WritePTY ((uchar *)p, num_bytes); WritePTY ((const uchar *)string.String(), string.Length());
return; return;
@@ -2073,7 +2086,6 @@ TermView::SubstMetaChar (const char *p, char *q)
void void
TermView::WritePTY (const uchar *text, int num_bytes) TermView::WritePTY (const uchar *text, int num_bytes)
{ {
if (gNowCoding != M_UTF8) { if (gNowCoding != M_UTF8) {
uchar *dstbuf = (uchar *)malloc (num_bytes * 3); uchar *dstbuf = (uchar *)malloc (num_bytes * 3);
num_bytes = fCodeConv->ConvertFromInternal(text, dstbuf, gNowCoding); num_bytes = fCodeConv->ConvertFromInternal(text, dstbuf, gNowCoding);