Terminal: added argv for initial working directory

Change-Id: I82ea0e358d037d79f2a7ffb59f83cf6e3d72d4a6
Reviewed-on: https://review.haiku-os.org/c/780
Reviewed-by: Adrien Destugues <[email protected]>
This commit is contained in:
lazybullfrog
2019-01-22 17:53:03 +00:00
committed by waddlesplash
parent 3f77fdd1d2
commit dace9ead09
4 changed files with 61 additions and 29 deletions
+17 -5
View File
@@ -1,6 +1,12 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Copyright 2005-2019, Haiku, Inc. All rights reserved.
* Copyright 2005, Ingo Weinhold, <[email protected]>
*
* Distributed under the terms of the MIT License.
*
* Authors:
* Jeremiah Bailey, <[email protected]>
* Ingo Weinhold, <[email protected]>
*/
@@ -25,7 +31,8 @@ Arguments::Arguments(int defaultArgsNum, const char* const* defaultArgs)
fFullScreen(false),
fShellArgumentCount(0),
fShellArguments(NULL),
fTitle(NULL)
fTitle(NULL),
fWorkingDirectory(NULL)
{
_SetShellArguments(defaultArgsNum, defaultArgs);
}
@@ -53,9 +60,14 @@ Arguments::Parse(int argc, const char* const* argv)
fUsageRequested = true;
else
fTitle = argv[++argi];
} else if (strcmp(arg, "-f") == 0 || strcmp(arg, "--fullscreen")
== 0)
} else if (strcmp(arg, "-w") == 0
|| strcmp(arg, "--working-directory") == 0) {
if (argi >= argc)
fUsageRequested = true;
else
fWorkingDirectory = argv[++argi];
} else if (strcmp(arg, "-f") == 0
|| strcmp(arg, "--fullscreen") == 0)
fFullScreen = true;
else {
// illegal option
+15 -6
View File
@@ -1,8 +1,15 @@
/*
* Copyright 2005, Ingo Weinhold, [email protected].
* Copyright 2005-2018, Haiku, Inc. All rights reserved.
* Copyright 2005, Ingo Weinhold, <[email protected]>
*
* Distributed under the terms of the MIT License.
*
* Authors:
* Jeremiah Bailey, <[email protected]>
* Ingo Weinhold, <[email protected]>
*/
#ifndef ARGUMENTS_H
#define ARGUMENTS_H
@@ -15,11 +22,12 @@ public:
void Parse(int argc, const char* const* argv);
BRect Bounds() const { return fBounds; }
const char* Title() const { return fTitle; }
bool StandardShell() const { return fStandardShell; }
bool FullScreen() const { return fFullScreen; }
bool UsageRequested() const { return fUsageRequested; }
BRect Bounds() const { return fBounds; }
const char* Title() const { return fTitle; }
const char* WorkingDir() const { return fWorkingDirectory; }
bool StandardShell() const { return fStandardShell; }
bool FullScreen() const { return fFullScreen; }
bool UsageRequested() const { return fUsageRequested; }
void GetShellArguments(int& argc, const char* const*& argv) const;
private:
@@ -32,6 +40,7 @@ private:
int fShellArgumentCount;
const char** fShellArguments;
const char* fTitle;
const char* fWorkingDirectory;
};
+21 -14
View File
@@ -1,13 +1,14 @@
/*
* Copyright 2001-2013, Haiku, Inc. All rights reserved.
* Copyright 2001-2019, Haiku.
* Copyright (c) 2003-2004 Kian Duffy <[email protected]>
* Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed unter the terms of the MIT license.
*
* Authors:
* Kian Duffy, [email protected]
* Siarzhuk Zharski, [email protected]
* Jeremiah Bailey, <[email protected]>
* Kian Duffy, <[email protected]>
* Siarzhuk Zharski, <[email protected]>
*/
@@ -204,6 +205,11 @@ TermApp::ArgvReceived(int32 argc, char **argv)
if (fArgs->Title() != NULL)
fWindowTitle = fArgs->Title();
if (fArgs->WorkingDir() != NULL) {
fWorkingDirectory = fArgs->WorkingDir();
chdir(fWorkingDirectory);
}
fStartFullscreen = fArgs->FullScreen();
}
@@ -299,7 +305,7 @@ TermApp::_ChildCleanupThreadEntry(void* data)
return ((TermApp*)data)->_ChildCleanupThread();
}
status_t
TermApp::_ChildCleanupThread()
{
@@ -307,7 +313,7 @@ TermApp::_ChildCleanupThread()
sigemptyset(&waitForSignals);
sigaddset(&waitForSignals, SIGCHLD);
sigaddset(&waitForSignals, SIGUSR1);
for (;;) {
int signal;
int error = sigwait(&waitForSignals, &signal);
@@ -327,18 +333,19 @@ void
TermApp::_Usage(char *name)
{
fprintf(stderr, B_TRANSLATE("Haiku Terminal\n"
"Copyright 2001-2009 Haiku, Inc.\n"
"Copyright 2001-2019 Haiku, Inc.\n"
"Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n"
"\n"
"Usage: %s [OPTION] [SHELL]\n"), name);
fprintf(stderr,
B_TRANSLATE(" -h, --help print this help\n"
//" -p, --preference load preference file\n"
" -t, --title set window title\n"
" -f, --fullscreen start fullscreen\n")
//" -geom, --geometry set window geometry\n"
//" An example of geometry is \"80x25+100+100\"\n"
fprintf(stderr, B_TRANSLATE(
" -h, --help print this help\n"
//" -p, --preference load preference file\n"
" -t, --title set window title\n"
" -f, --fullscreen start fullscreen\n"
" -w, --working-directory set initial working directory\n")
//" -geom, --geometry set window geometry\n"
//" An example of geometry is \"80x25+100+100\"\n"
);
}
+8 -4
View File
@@ -1,14 +1,17 @@
/*
* Copyright 2001-2013, Haiku.
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
* Copyright 2001-2018, Haiku.
* Copyright (c) 2003-2004 Kian Duffy <[email protected]>
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
*
* Distributed under the terms of the MIT License.
*
* Authors:
* Kian Duffy, [email protected]
* Siarzhuk Zharski, [email protected]
* Jeremiah Bailey, <[email protected]>
* Kian Duffy, <[email protected]>
* Siarzhuk Zharski, <[email protected]>
*/
#ifndef TERM_APP_H
#define TERM_APP_H
@@ -54,6 +57,7 @@ private:
bool fTerminating;
bool fStartFullscreen;
BString fWindowTitle;
BString fWorkingDirectory;
BWindow* fTermWindow;
Arguments* fArgs;