[GRASS-dev] howto rewrite r.colors using G_message and G_warning
Jachym Cepicky
jachym.cepicky at centrum.cz
Tue Sep 26 12:26:21 EDT 2006
thank you, Glynn,
jachym
On Tue, Sep 26, 2006 at 05:14:43PM +0100, Glynn Clements wrote:
>
> Jachym Cepicky wrote:
>
> > i have question considering replacing fprintf functions with
> > G_message and G_warning in GRASS modules.
> >
> > Currently, i come to r.colors, which structure is very complicated. This
> > module can be also run in interactive mode:
> >
> > r.colors pokus color=rules
> > Enter rules, "end" when done, "help" if you need it.
> > Data range is 1 to 683
> > >
> >
> > I'm not shure, if these strings should be printed using G_message or if
> > they should stay untouched. I'm also not shure, if the module needs this
> > interactive mode at all - if it should not better be removed (and the
> > structure of the module would be simplified).
>
> It isn't necessarily an "interactive" mode; you can just as easily
> read the rules from a file by redirecting stdin (in which case, the
> text and prompts won't be displayed).
>
> [However, r.colors probably should have a file= option; this would
> probably be more useful from a GUI. Alternatively, there should be
> some way to tell G_parser() that a module may read from stdin so that
> the GUI can add a button to allow stdin to be redirected from a file
> of the user's choice.]
>
> I suggest not converting this code to use G_message(). You can't use
> it for the prompt (G_message() adds a newline), and the information
> should (IMHO) be displayed even if verbosity is not enabled.
>
> > If the interactive mode should remain untached, maybe functions
> > G_tty() and G_promt() should be introduced:
> >
> > G_tty(_(Enter rules, "end" when done, "help" if you need it.));
> > G_promt()
>
> I don't see any need.
>
> IMHO, the migration to the use of G_message() is primarily for the
> benefit of non-interactive modules.
>
> > which would show
> >
> > Enter rules, "end" when done, "help" if you need it.
> > >
> >
> > Could anybody give advice how to approach to modules like r.colors?
>
> So far as G_message() migration is concerned, don't worry about
> interactive cases.
>
> --
> Glynn Clements <glynn at gclements.plus.com>
--
Jachym Cepicky
e-mail: jachym.cepicky at centrum.cz
URL: http://les-ejk.cz
GPG: http://les-ejk.cz/gnupg_public_key/jachym_cepicky-gpg_public_key.asc
-----------------------------------------
OFFICE:
GDF-Hannover
Mengendamm 16d
30177 Hannover
Germany
e-mail: cepicky at gdf-hannover.de
URL: http://gdf-hannover.de
Tel.: +49 511-39088507
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Digital signature
Url : http://lists.osgeo.org/pipermail/grass-dev/attachments/20060926/6d312bdc/attachment.bin
More information about the grass-dev
mailing list