Re: How about the argument ``-nosplash'' in ap_UnixApp.cpp

Jeff Hostetler (jeff@abisource.com)
Wed, 16 Jun 1999 11:05:35 -0500


i send my last response before i received your second

messge last night (chicago time), so when i wrote my

data structure discussion i hadn't seen your getopt_long

table stuff.

parse command line should be done first and build a list

of filenames to open and maybe update the option variable

settings. then show the splash. this needs to occur

quickly -- you want the splash to occupy the user's eye

while they wait for the document windows to open.

then (while the splash is up) go thru and start creating

document windows and opening document files -- this can

take a while -- depending upon the speed of the machine

and the bandwidth of the X connection and the size of the

document on disk. this is why i was suggesting a ut_vector

of filenames -- accumulate them in the parse and then

wait and open them one by one later on by walking thru the

vector.

as for the getopt table of values, i've not had a chance

to read the man page on it, so i'll have to let you and

Shaw discuss this. (i'm leaving for vacation tomorrow)

as for the list of options what we need, the list that i

noted in pseudo-BNF in the comment block is a good start.

i would add --help as is the style and the usage dump as

is typical.

jeff

At 07:22 PM 6/16/99 +0800, Ming-I Hsieh wrote:

>>>>

<excerpt><excerpt>Jeff Hostetler wrote: yes, we should probably do a
parse at the very beginning

and probably set some App member variables or globals or

something and then let the splash code and the later code

which processes everything else to just reference them.

the reason that we have 2 distinct places which look thru

argv is historical. originally, the only thing we did

with the command line was get the (single, optional)

filename -- and we didn't need it until all the class

registration and the initial window and all its widgets

were created -- this could take some time.

if we let the parse code populate a ut_hash or ut_alphahash

of the arguments (and their optional values) of the keywords

and a ut_vector of the filenames to load, then everything

should be fine. these could be stored in XAP_App -- the

absolute base class for the application and then referenced

wherever....

and yes, let getopt do all the parsing dirty work in cross-

platform code....

thoughts ?? opinions ??

</excerpt>jeff If we use getopt_long, I think we should check the
argument, --nosplash, in

ParseCommandLine, and we should call _showSplash in ParseCommandLine,

not main.

Do we need an usage like: ?

gzip 1.2.4 (18 Aug 93)

usage: gzip [-cdfhlLnNrtvV19] [-S suffix] [file ...]

-c --stdout write on standard output, keep original files unchanged

-d --decompress decompress

-f --force force overwrite of output file and compress links

-h --help give this help

-l --list list compressed file contents

-L --license display software license

-n --no-name do not save or restore the original name and time stamp

-N --name save or restore the original name and time stamp

-q --quiet suppress all warnings

-r --recursive operate recursively on directories

-S .suf --suffix .suf use suffix .suf on compressed files

-t --test test compressed file integrity

-v --verbose verbose mode

-V --version display version number

-1 --fast compress faster

-9 --best compress better

file... files to (de)compress. If none given, use standard
input.

And what option do we need?

-s

-d

-l

-n

????? :)

-- following are a sample of ParseCommandLine() using getopt_long;

#include "getopt.h"

struct option longopts[] =

{

{"script", 1, 0, 's'},

{"dumpstrings", 0, 0, 'd'},

{"lib", 1, 0, 'l'},

<color><param>ffff,0000,0000</param> {"nosplash", 0, 0,
'n'},</color>

{0, 0, 0, 0 }

};

void AP_UnixApp::ParseCommandLine(void)

{

// parse the command line

// <<app> [--script <<scriptname>]* [--dumpstrings]

// [--lib <<AbiSuiteLibDirectory>] [<<documentname>]*


// TODO when we refactor the App classes, consider moving

// TODO this to app-specific, cross-platform.

// TODO replace this with getopt or something similar.


// Unix puts the program name in argv[0], so [1] is the first
argument.

int k;

int kWindowsOpened = 0;

<color><param>ffff,0000,0000</param> UT_Bool bShowSplash =
UT_TRUE;</color>

while ((k = getopt_long(m_pArgs->m_argc, m_pArgs->m_argv,
"s:d<color><param>ffff,0000,0000</param>n</color>l:",

longopts, (int *)0)) != EOF) {

switch (k) {

case 's':

// [--script scriptname]

break;

case 'd':

#ifdef DEBUG

{

AP_BuiltinStringSet * pBuiltinStringSet =

new AP_BuiltinStringSet(this,

AP_PREF_DEFAULT_StringSet);

pBuiltinStringSet->dumpBuiltinSet("EnUS.strings");

delete pBuiltinStringSet;

}

#endif

break;

<color><param>ffff,0000,0000</param> case 'n':</color>

<color><param>ffff,0000,0000</param> bShowSplash =
UT_FALSE;</color>

<color><param>ffff,0000,0000</param> break;</color>

case 'l':

// [--lib <<AbiSuiteLibDirectory>]

// we've already processed this when we
initialized

// the App class

break;

default:

UT_DEBUGMSG(("Unknown command line option [%s]\n",

m_pArgs->m_argv[optind]));

// TODO don't know if it has a following argument

// or not -- assume not

break;

}

}

AP_UnixFrame *pFirstUnixFrame = new AP_UnixFrame(this);

pFirstUnixFrame->initialize();

while (optind << m_pArgs->m_argc) {

if (pFirstUnixFrame == NULL) {

pFirstUnixFrame = new AP_UnixFrame(this);

pFirstUnixFrame->initialize();

kWindowsOpened++;

}

if (pFirstUnixFrame->loadDocument(m_pArgs->m_argv[optind],

IEFT_Unknown)) {

pFirstUnixFrame = NULL;

} else {

// A simple message box to tell user that we

// can't open a bogus pathname! :)

char message[2048];

g_snprintf(message, 2048,

"Cannot open file %s.", m_pArgs->m_argv[optind]);

messageBoxOK(message);

}

optind++;

}

if (pFirstUnixFrame != NULL) {

if (kWindowsOpened == 0) {

pFirstUnixFrame->loadDocument(NULL, IEFT_Unknown);

} else {

forgetFrame(pFirstUnixFrame);

delete pFirstUnixFrame;

}

}

<color><param>ffff,0000,0000</param>if (bShowSplash)
_showSplash(NULL, NULL);</color>

}

</excerpt>



This archive was generated by hypermail 1.03b2.