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
+77 -65
View File
@@ -1815,62 +1815,75 @@ TermView::FrameResized (float width, float height)
void void
TermView::MessageReceived(BMessage *msg) TermView::MessageReceived(BMessage *msg)
{ {
entry_ref ref; entry_ref ref;
char *ctrl_l = " "; char *ctrl_l = " ";
switch(msg->what){ switch(msg->what){
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
if (msg->FindRef("refs", &ref) == B_OK ){ {
this->DoFileDrop(ref); int32 i=0;
} else { if(msg->FindRef("refs", i++, &ref) == B_OK)
BView::MessageReceived(msg); {
} this->DoFileDrop(ref);
break;
case B_MIME_DATA: while(msg->FindRef("refs", i++, &ref) == B_OK)
char *text; this->DoFileDrop(ref);
int32 num_bytes; }
status_t sts; else
{
BView::MessageReceived(msg);
}
break;
}
case B_MIME_DATA:
{
char *text;
int32 num_bytes;
status_t sts;
if (msg->WasDropped()){ if (msg->WasDropped())
sts = msg->FindData ((const char *)"text/plain", {
(type_code)B_MIME_TYPE, sts = msg->FindData ((const char *)"text/plain",
(const void **)&text, (type_code)B_MIME_TYPE,
&num_bytes); (const void **)&text, &num_bytes);
if (sts != B_OK)
break;
if (sts != B_OK) break; // Clipboard text doesn't attached EOF?
text[num_bytes] = '\0';
/* Clipboard text doesn't attached EOF? */ WritePTY ((uchar *)text, num_bytes);
text[num_bytes] = '\0'; }
WritePTY ((uchar *)text, num_bytes); break;
}
} case B_COPY:
break; {
this->DoCopy();
break;
case B_COPY: }
this->DoCopy(); case B_PASTE:
break; {
int32 code;
case B_PASTE: if (msg->FindInt32 ("index", &code) == B_OK)
int32 code; this->DoPaste();
if (msg->FindInt32 ("index", &code) == B_OK) break;
this->DoPaste(); }
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 (); {
break; this->BlinkCursor();
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,16 +1921,15 @@ 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);
BPath path(&ent);
BString string(path.Path());
BEntry ent(&ref); string.CharacterEscape(" ~`#$&*()\\|[]{};'\"<>?!",'\\');
BPath path(&ent); string+=" ";
WritePTY ((const uchar *)string.String(), string.Length());
int num_bytes = SubstMetaChar (path.Path(), p); return;
WritePTY ((uchar *)p, num_bytes);
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);