Re: [AD] log window

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


On 2010-07-05, Elias Pschernig <elias.pschernig@xxxxxxxxxx> wrote:
> On Mon, 2010-07-05 at 12:05 +1000, Peter Wang wrote:
> 
> > For non-example uses, we should limit the size of the log.  Probably a
> > fixed limit of 1000 lines or so is good enough.
> > 
> 
> True. Maybe with an unlimited flag since some things can generate a lot
> of log lines. My terminal's scrollback buffer is set to 50 000 lines and
> I think I still scroll all the way up occasionally and am annoyed when
> the initial lines are lost :P
> 
> I wonder if we also should provide functions to clear the buffer or read
> back its contents. The latter could be useful especially if we keep the
> log window editable. Probably going overboard with this now though.
> 

Do you want to commit this?  (after making the other ports still compile)
I can do it if you're busy.

>  extern int _al_show_native_message_box(ALLEGRO_DISPLAY *display,
>     ALLEGRO_NATIVE_DIALOG *fd);
> +extern void _al_open_native_log_window(ALLEGRO_NATIVE_DIALOG *textlog);
> +extern void _al_close_native_log_window(ALLEGRO_NATIVE_DIALOG *textlog);
> +void _al_append_to_textlog(ALLEGRO_NATIVE_DIALOG *textlog);

_al_append_to_log_window

> +/* Function: al_show_native_textlog
> + */
> +ALLEGRO_NATIVE_DIALOG *al_open_native_log_window(
> +   char const *title, int flags)

Function name doesn't match.

> +
> +void al_close_native_log_window(ALLEGRO_NATIVE_DIALOG *textlog)
> +{

Missing Function: header.

> +
> +void al_append_log(ALLEGRO_NATIVE_DIALOG *textlog,
> +   char const *format, ...)

Should we name this al_append_[native_]log_window ? 

> +{
> +   al_lock_mutex(textlog->text_mutex);
> +   /* TODO: If we had an al_ustr_newv which can take the format
> +    * parameter and a va_list, it would be easy doing this without a
> +    * fixed buffer size...
> +    */
> +   char text[1024];
> +   va_list args;
> +   va_start(args, format);
> +   vsnprintf(text, sizeof text, format, args);
> +   va_end(args);
> +   textlog->text = al_ustr_new(text);

You can use al_ustr_new and al_ustr_appendf.

> +/* Function: al_get_audio_stream_event_source
> + */
> +ALLEGRO_EVENT_SOURCE *al_get_native_dialog_event_source(
> +   ALLEGRO_NATIVE_DIALOG *dialog)
> +{
> +   return &dialog->events;
> +}

Copy-pasted header.

ASSERT(dialog);

> diff --git a/docs/src/refman/native_dialog.txt b/docs/src/refman/native_dialog.txt
> index b76afdf..8545a01 100644
> --- a/docs/src/refman/native_dialog.txt
> +++ b/docs/src/refman/native_dialog.txt
> @@ -121,3 +121,34 @@ Example:
>  
>  Returns the (compiled) version of the addon, in the same format as
>  [al_get_allegro_version].
> +
> +## API: al_open_native_log_window
> +
> +Shows a text window to which you can append log messages with

Opens a window to which ...

> +[al_append_log]. This can be useful for debugging if you don't want
> +to depend on a console being available.
> +
> +Use [al_close_native_log_window] to close the window again.
> +
> +The only flag so far is ALLEGRO_MESSAGELOG_NO_CLOSE - if will prevent

it will prevent ...

> +the window from having a close button. Otherwise if the close button
> +is pressed an event is generated, see

incomplete sentence.

Returns NULL if there was an error opening the log window,
or if log windows are not implemented on the platform.

> +## API: al_close_native_log_window
> +
> +Closes a message log window opened with [al_open_native_log_window]
> +earlier.

Does nothing if passed NULL.

> +
> +## API: al_append_log
> +
> +Appends a line of text to the message log window and scrolls to the
> +bottom (if the line would not be visible otherwise). This works like
> +printf. A line is continued until you add a newline character.

If this falls back to printf when called with a NULL window, then it
would be very easy to choose between a log window or terminal at
runtime.

Peter




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/