[ Thread Index |
| More lists.liballeg.org/allegro-developers Archives
On Mon, Jul 12, 2010 at 9:01 AM, Peter Wang <novalazy@xxxxxxxxxx>
> > For non-example uses, we should limit the size of the log. Probably aDo you want to commit this? (after making the other ports still compile)
> > 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.
I can do it if you're busy.
Earliest I would be able to is Wednesday. If it's committed by then maybe I'll see how far I get with a windows or OSX version instead.
> 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);
> +/* 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 ?
Yes, I'd say so. It's easy to do:
#define print al_append_native_log_window
or something like that in code where you have lots of log messages and the name would be a bit long.
> + 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;
> + 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.
Hm, I don't see how. I would need an al_ustr_appendv. From what I see we have nothing which takes a va_list as parameter right now. And I was too lazy to check if it would be easy to add.
> +/* Function: al_get_audio_stream_event_source
> + */
> +ALLEGRO_EVENT_SOURCE *al_get_native_dialog_event_source(
> + ALLEGRO_NATIVE_DIALOG *dialog)
> + return &dialog->events;
Ah, how embarassing that I had to copy that from somewhere :P
> 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
> +## 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
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]
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
True, sounds like a good idea.