GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
AG_CONSOLE(3) FreeBSD Library Functions Manual AG_CONSOLE(3)

AG_Consoleagar log console widget

#include <agar/core.h>
#include <agar/gui.h>

AG_Console displays a scrollable list of messages in a log format. Log entries can be copied to the clipboard or exported to a file. The contents and attributes of existing log entries can be updated dynamically.

AG_Object(3) -> AG_Widget(3) -> AG_Console.

AG_Console *
(AG_Widget *parent, Uint flags);

The () function allocates, initializes, and attaches a new AG_Console widget. Acceptable flags include:

AG_CONSOLE_NOAUTOSCROLL
Don't scroll automatically to make newly inserted lines visible.
AG_CONSOLE_NOPOPUP
Disable the right-click contextual popup menu (with Copy, Select All and Export functions).
AG_CONSOLE_HFILL
Expand horizontally in parent container.
AG_CONSOLE_VFILL
Expand vertically in parent container.
AG_CONSOLE_EXPAND
Shorthand for AG_CONSOLE_HFILL | .

AG_ConsoleLine *
AG_ConsoleMsg(AG_Console *cons, const char *format, ...);


AG_ConsoleLine *
(AG_Console *cons, const char *s);


AG_ConsoleLine *
(AG_Console *cons, const void *data, AG_Size data_size, const char *label, const char *format);


void
(AG_ConsoleLine *line, const char *s);


void
(AG_ConsoleLine *line, const char *s);


void
(AG_ConsoleLine *line, void *ptr);


void
(AG_ConsoleLine *line, const AG_Color *c);


void
(AG_Console *cons);


char *
(AG_Console *cons, enum ag_newline_type newline);


char *
(AG_Console *cons, enum ag_newline_type newline);

The () function appends a new message to the console log. Unless an error occurs, the function returns a pointer to the created AG_ConsoleLine. If the message contains newlines, create a group of lines (which will be displayed in an indented style) and return a pointer to the first line (which will be the parent of the subsequent lines). The returned AG_ConsoleLine remains valid until deleted (or AG_ConsoleClear() is used).

As a special case, if a cons argument of NULL is passed to () then the message is passed to AG_Verbose(3) (and the function returns NULL).

() displays binary data in canonical hex+ASCII format. If non-NULL, label is prepended to every line. If non-NULL, format specifies an alternate format string (such as "%02d " for decimal). The default format is "%02x ". The format string must generate 3 characters.

() replaces an existing log entry's text with the given string.

() appends the given string to an existing log entry's text.

() sets an optional user pointer for this log entry.

() sets an alternate, line-specific color for this log entry.

() clears all messages from the console.

() returns a C string containing all currently selected lines, joined by newlines of the given variety. Similarly, AG_ConsoleExportBuffer() joins all lines in the buffer with the specified type of newline.

AG_ConsoleFile *
AG_ConsoleOpenFile(AG_Console *cons, const char *label, const char *file, enum ag_newline_type newline, Uint flags);


AG_ConsoleFile *
(AG_Console *cons, const char *label, int fd, enum ag_newline_type newline, Uint flags);


AG_ConsoleFile *
(AG_Console *cons, const char *label, FILE *f, enum ag_newline_type newline, Uint flags);


void
(AG_Console *cons, AG_ConsoleFile *cf);

() opens a file for reading, displays its contents on the console and then arranges for AG_Console to follow changes made to the file (similar to "tail -f" in Unix). Internally the function uses AG_AddEventSink(3) to set up an event sink of type AG_SINK_READ on the open file descriptor.

The newline argument indicates the style of newline to use:

enum ag_newline_type {
	AG_NEWLINE_LF,    /* Unix, Amiga, BeOS, Multics, RISC OS */
	AG_NEWLINE_CR_LF, /* DOS/Windows, early non-Unix */
	AG_NEWLINE_CR,    /* Commodore 8-bit machines (C64/128) */
};

Possible flags include:

#define AG_CONSOLE_FILE_BINARY     0x01  /* Binary hex dump */
#define AG_CONSOLE_FILE_LEAVE_OPEN 0x02  /* Don't close fd on detach */

If AG_CONSOLE_FILE_BINARY is used then AG_Console produces a canonical hex+ASCII dump of the file (and any changes to it).

The AG_CONSOLE_FILE_LEAVE_OPEN option causes () to leave the file descriptor (or FILE * handle) open.

The () variant accepts an integer file descriptor, and () accepts the FILE * handle of an open stream.

() closes a file being followed.

The AG_Console widget does not generate any event.

For the AG_Console object:

int pos
Current cursor position (or -1).
int sel
Selection (offset from cursor).
AG_Mutex lock
Lock on buffer contents.
AG_ConsoleLine **lines
Lines in buffer.
Uint nLines
Line count.

For the AG_ConsoleLine structure:

char *text
Text string.
AG_Size len
Length of string in characters.
int selected
Line selection flag.
int icon
Icon surface to display.
AG_Color cFg
Foreground color.
AG_Color cBg
Background color.
void *p
User pointer

AG_Color(3), AG_Intro(3), AG_Text(3), AG_Textbox(3), AG_Widget(3), AG_Window(3)

The AG_Console widget first appeared in Agar 1.3.4. In Agar 1.6.0, AG_ConsoleSetPadding() was deprecated by the generic "padding" style attribute. Agar 1.6.0 added support for multi-line entries and introduced AG_ConsoleOpenFile(), AG_ConsoleOpenFD(), AG_ConsoleOpenStream(), AG_ConsoleClose(), AG_ConsoleMsgCatS(), AG_ConsoleBinary() and AG_ConsoleExportBuffer().

December 21, 2022 Agar 1.7

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.