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:
committed by
waddlesplash
parent
3f77fdd1d2
commit
dace9ead09
@@ -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.
|
* 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),
|
fFullScreen(false),
|
||||||
fShellArgumentCount(0),
|
fShellArgumentCount(0),
|
||||||
fShellArguments(NULL),
|
fShellArguments(NULL),
|
||||||
fTitle(NULL)
|
fTitle(NULL),
|
||||||
|
fWorkingDirectory(NULL)
|
||||||
{
|
{
|
||||||
_SetShellArguments(defaultArgsNum, defaultArgs);
|
_SetShellArguments(defaultArgsNum, defaultArgs);
|
||||||
}
|
}
|
||||||
@@ -53,9 +60,14 @@ Arguments::Parse(int argc, const char* const* argv)
|
|||||||
fUsageRequested = true;
|
fUsageRequested = true;
|
||||||
else
|
else
|
||||||
fTitle = argv[++argi];
|
fTitle = argv[++argi];
|
||||||
|
} else if (strcmp(arg, "-w") == 0
|
||||||
} else if (strcmp(arg, "-f") == 0 || strcmp(arg, "--fullscreen")
|
|| strcmp(arg, "--working-directory") == 0) {
|
||||||
== 0)
|
if (argi >= argc)
|
||||||
|
fUsageRequested = true;
|
||||||
|
else
|
||||||
|
fWorkingDirectory = argv[++argi];
|
||||||
|
} else if (strcmp(arg, "-f") == 0
|
||||||
|
|| strcmp(arg, "--fullscreen") == 0)
|
||||||
fFullScreen = true;
|
fFullScreen = true;
|
||||||
else {
|
else {
|
||||||
// illegal option
|
// illegal option
|
||||||
|
|||||||
@@ -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.
|
* Distributed under the terms of the MIT License.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Jeremiah Bailey, <[email protected]>
|
||||||
|
* Ingo Weinhold, <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef ARGUMENTS_H
|
#ifndef ARGUMENTS_H
|
||||||
#define ARGUMENTS_H
|
#define ARGUMENTS_H
|
||||||
|
|
||||||
@@ -15,11 +22,12 @@ public:
|
|||||||
|
|
||||||
void Parse(int argc, const char* const* argv);
|
void Parse(int argc, const char* const* argv);
|
||||||
|
|
||||||
BRect Bounds() const { return fBounds; }
|
BRect Bounds() const { return fBounds; }
|
||||||
const char* Title() const { return fTitle; }
|
const char* Title() const { return fTitle; }
|
||||||
bool StandardShell() const { return fStandardShell; }
|
const char* WorkingDir() const { return fWorkingDirectory; }
|
||||||
bool FullScreen() const { return fFullScreen; }
|
bool StandardShell() const { return fStandardShell; }
|
||||||
bool UsageRequested() const { return fUsageRequested; }
|
bool FullScreen() const { return fFullScreen; }
|
||||||
|
bool UsageRequested() const { return fUsageRequested; }
|
||||||
void GetShellArguments(int& argc, const char* const*& argv) const;
|
void GetShellArguments(int& argc, const char* const*& argv) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -32,6 +40,7 @@ private:
|
|||||||
int fShellArgumentCount;
|
int fShellArgumentCount;
|
||||||
const char** fShellArguments;
|
const char** fShellArguments;
|
||||||
const char* fTitle;
|
const char* fTitle;
|
||||||
|
const char* fWorkingDirectory;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -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) 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.
|
* Distributed unter the terms of the MIT license.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Kian Duffy, [email protected]
|
* Jeremiah Bailey, <[email protected]>
|
||||||
* Siarzhuk Zharski, [email protected]
|
* Kian Duffy, <[email protected]>
|
||||||
|
* Siarzhuk Zharski, <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
@@ -204,6 +205,11 @@ TermApp::ArgvReceived(int32 argc, char **argv)
|
|||||||
if (fArgs->Title() != NULL)
|
if (fArgs->Title() != NULL)
|
||||||
fWindowTitle = fArgs->Title();
|
fWindowTitle = fArgs->Title();
|
||||||
|
|
||||||
|
if (fArgs->WorkingDir() != NULL) {
|
||||||
|
fWorkingDirectory = fArgs->WorkingDir();
|
||||||
|
chdir(fWorkingDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
fStartFullscreen = fArgs->FullScreen();
|
fStartFullscreen = fArgs->FullScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -327,18 +333,19 @@ void
|
|||||||
TermApp::_Usage(char *name)
|
TermApp::_Usage(char *name)
|
||||||
{
|
{
|
||||||
fprintf(stderr, B_TRANSLATE("Haiku Terminal\n"
|
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"
|
"Copyright(C) 1999 Kazuho Okui and Takashi Murai.\n"
|
||||||
"\n"
|
"\n"
|
||||||
"Usage: %s [OPTION] [SHELL]\n"), name);
|
"Usage: %s [OPTION] [SHELL]\n"), name);
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr, B_TRANSLATE(
|
||||||
B_TRANSLATE(" -h, --help print this help\n"
|
" -h, --help print this help\n"
|
||||||
//" -p, --preference load preference file\n"
|
//" -p, --preference load preference file\n"
|
||||||
" -t, --title set window title\n"
|
" -t, --title set window title\n"
|
||||||
" -f, --fullscreen start fullscreen\n")
|
" -f, --fullscreen start fullscreen\n"
|
||||||
//" -geom, --geometry set window geometry\n"
|
" -w, --working-directory set initial working directory\n")
|
||||||
//" An example of geometry is \"80x25+100+100\"\n"
|
//" -geom, --geometry set window geometry\n"
|
||||||
|
//" An example of geometry is \"80x25+100+100\"\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2001-2013, Haiku.
|
* Copyright 2001-2018, Haiku.
|
||||||
* Copyright (c) 2003-4 Kian Duffy <[email protected]>
|
* Copyright (c) 2003-2004 Kian Duffy <[email protected]>
|
||||||
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
* Parts Copyright (C) 1998,99 Kazuho Okui and Takashi Murai.
|
||||||
*
|
*
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
* Kian Duffy, [email protected]
|
* Jeremiah Bailey, <[email protected]>
|
||||||
* Siarzhuk Zharski, [email protected]
|
* Kian Duffy, <[email protected]>
|
||||||
|
* Siarzhuk Zharski, <[email protected]>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifndef TERM_APP_H
|
#ifndef TERM_APP_H
|
||||||
#define TERM_APP_H
|
#define TERM_APP_H
|
||||||
|
|
||||||
@@ -54,6 +57,7 @@ private:
|
|||||||
bool fTerminating;
|
bool fTerminating;
|
||||||
bool fStartFullscreen;
|
bool fStartFullscreen;
|
||||||
BString fWindowTitle;
|
BString fWindowTitle;
|
||||||
|
BString fWorkingDirectory;
|
||||||
|
|
||||||
BWindow* fTermWindow;
|
BWindow* fTermWindow;
|
||||||
Arguments* fArgs;
|
Arguments* fArgs;
|
||||||
|
|||||||
Reference in New Issue
Block a user