what am i doing

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@79 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-30 12:34:18 +00:00
parent 5207cc8c63
commit aa4ba428ec
3 changed files with 388 additions and 19 deletions

View File

@@ -6,22 +6,66 @@
<body> <body>
<h1 align="center">Milsko GUI Toolkit Documentation</h1> <h1 align="center">Milsko GUI Toolkit Documentation</h1>
<hr> <hr>
<h2 align="center">Mw/Button.h</h2> <h2 align="center">Table of Contents</h2>
<p> <dl>
Button widget. <dt>
</p> <a href="#Mw_Button_h">Mw/Button.h</a>
</dt>
<dd>
<a href="#Mw_Button_h__MwButtonClass">MwButtonClass</a>
</dd>
<dt>
<a href="#Mw_Core_h">Mw/Core.h</a>
</dt>
<dd>
<a href="#Mw_Core_h__MwDispatch">MwDispatch</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwCreateWidget">MwCreateWidget</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwVaCreateWidget">MwVaCreateWidget</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwVaListCreateWidget">MwVaListCreateWidget</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwDestroyWidget">MwDestroyWidget</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwLoop">MwLoop</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwStep">MwStep</a>
</dd>
<dd>
<a href="#Mw_Core_h__MwPending">MwPending</a>
</dd>
</dl>
<hr> <hr>
<pre><code>MWDECL MwClass MwButtonClass;</code></pre> <h2 align="center" id="Mw_Button_h">Mw/Button.h</h2>
<dl>
<dt>
Button widget.
</dt>
</dl>
<hr>
<pre id="Mw_Button_h__MwButtonClass"><code>MWDECL MwClass MwButtonClass;</code></pre>
<dl>
<dd> <dd>
Button class. Button class.
</dd> </dd>
</dl>
<hr> <hr>
<h2 align="center">Mw/Core.h</h2> <h2 align="center" id="Mw_Core_h">Mw/Core.h</h2>
<p> <dl>
<dt>
Core. Core.
</p> </dt>
</dl>
<hr> <hr>
<pre><code>#define MwDispatch(x, y)</code></pre> <pre id="Mw_Core_h__MwDispatch"><code>#define MwDispatch(x, y)</code></pre>
<dl>
<dd> <dd>
Dispatches a handler of widget class. Dispatches a handler of widget class.
</dd> </dd>
@@ -43,8 +87,9 @@
<dd> <dd>
Handler name. Handler name.
</dd> </dd>
</dl>
<hr> <hr>
<pre><code>MWDECL MwWidget MwCreateWidget ( <pre id="Mw_Core_h__MwCreateWidget"><code>MWDECL MwWidget MwCreateWidget (
MwClass widget_class, MwClass widget_class,
const char* name, const char* name,
MwWidget parent, MwWidget parent,
@@ -53,6 +98,7 @@
unsigned int width, unsigned int width,
unsigned int height unsigned int height
);</code></pre> );</code></pre>
<dl>
<dd> <dd>
Creates a widget. Creates a widget.
</dd> </dd>
@@ -98,6 +144,219 @@
<dd> <dd>
Height. Height.
</dd> </dd>
<dt>
Returns
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwVaCreateWidget"><code>MWDECL MwWidget MwVaCreateWidget (
MwClass widget_class,
const char* name,
MwWidget parent,
int x,
int y,
unsigned int width,
unsigned int height,
...
);</code></pre>
<dl>
<dd>
Creates a widget.
</dd>
<dt>
Parameter <code>widget_class</code>
</dt>
<dd>
Widget class.
</dd>
<dt>
Parameter <code>name</code>
</dt>
<dd>
Widget name.
</dd>
<dt>
Parameter <code>parent</code>
</dt>
<dd>
Parent widget or <code>NULL</code>.
</dd>
<dt>
Parameter <code>x</code>
</dt>
<dd>
X.
</dd>
<dt>
Parameter <code>y</code>
</dt>
<dd>
Y.
</dd>
<dt>
Parameter <code>width</code>
</dt>
<dd>
Width.
</dd>
<dt>
Parameter <code>height</code>
</dt>
<dd>
Height.
</dd>
<dt>
Parameter <code>...</code>
</dt>
<dd>
Same with MwVaApply.
</dd>
<dt>
Returns
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwVaListCreateWidget"><code>MWDECL MwWidget MwVaListCreateWidget (
MwClass widget_class,
const char* name,
MwWidget parent,
int x,
int y,
unsigned int width,
unsigned int height,
va_list va
);</code></pre>
<dl>
<dd>
Creates a widget.
</dd>
<dt>
Parameter <code>widget_class</code>
</dt>
<dd>
Widget class.
</dd>
<dt>
Parameter <code>name</code>
</dt>
<dd>
Widget name.
</dd>
<dt>
Parameter <code>parent</code>
</dt>
<dd>
Parent widget or <code>NULL</code>.
</dd>
<dt>
Parameter <code>x</code>
</dt>
<dd>
X.
</dd>
<dt>
Parameter <code>y</code>
</dt>
<dd>
Y.
</dd>
<dt>
Parameter <code>width</code>
</dt>
<dd>
Width.
</dd>
<dt>
Parameter <code>height</code>
</dt>
<dd>
Height.
</dd>
<dt>
Parameter <code>va</code>
</dt>
<dd>
Same with MwVaListApply.
</dd>
<dt>
Returns
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwDestroyWidget"><code>MWDECL void MwDestroyWidget (
MwWidget handle
);</code></pre>
<dl>
<dd>
Destroys the widget and its child widgets.
</dd>
<dt>
Parameter <code>handle</code>
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwLoop"><code>MWDECL void MwLoop (
MwWidget handle
);</code></pre>
<dl>
<dd>
Runs the main loop.
</dd>
<dt>
Parameter <code>handle</code>
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwStep"><code>MWDECL void MwStep (
MwWidget handle
);</code></pre>
<dl>
<dd>
Runs the single step.
</dd>
<dt>
Parameter <code>handle</code>
</dt>
<dd>
Widget.
</dd>
</dl>
<hr>
<pre id="Mw_Core_h__MwPending"><code>MWDECL int MwPending (
MwWidget handle
);</code></pre>
<dl>
<dd>
Check if any event is pending.
</dd>
<dt>
Parameter <code>handle</code>
</dt>
<dd>
Widget.
</dd>
<dt>
Returns
</dt>
<dd>
<code>1</code> if any event is pending.
</dd>
</dl>
<hr> <hr>
</body> </body>
</html> </html>

View File

@@ -33,15 +33,62 @@ extern "C" {
* %param y Y * %param y Y
* %param width Width * %param width Width
* %param height Height * %param height Height
* %return Widget
*/ */
MWDECL MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height); MWDECL MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height);
MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
MWDECL MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
MWDECL void MwDestroyWidget(MwWidget handle);
/*!
* %brief Creates a widget
* %param widget_class Widget class
* %param name Widget name
* %param parent Parent widget or `NULL`
* %param x X
* %param y Y
* %param width Width
* %param height Height
* %param ... Same with MwVaApply
* %return Widget
*/
MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
/*!
* %brief Creates a widget
* %param widget_class Widget class
* %param name Widget name
* %param parent Parent widget or `NULL`
* %param x X
* %param y Y
* %param width Width
* %param height Height
* %param va Same with MwVaListApply
* %return Widget
*/
MWDECL MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
/*!
* %brief Destroys the widget and its child widgets
* %param handle Widget
*/
MWDECL void MwDestroyWidget(MwWidget handle);
/*!
* %brief Runs the main loop
* %param handle Widget
*/
MWDECL void MwLoop(MwWidget handle); MWDECL void MwLoop(MwWidget handle);
/*!
* %brief Runs the single step
* %param handle Widget
*/
MWDECL void MwStep(MwWidget handle); MWDECL void MwStep(MwWidget handle);
MWDECL int MwPending(MwWidget handle);
/*!
* %brief Check if any event is pending
* %param handle Widget
* %return `1` if any event is pending
*/
MWDECL int MwPending(MwWidget handle);
MWDECL void MwSetInteger(MwWidget handle, const char* key, int n); MWDECL void MwSetInteger(MwWidget handle, const char* key, int n);
MWDECL void MwSetText(MwWidget handle, const char* key, const char* value); MWDECL void MwSetText(MwWidget handle, const char* key, const char* value);

View File

@@ -6,6 +6,9 @@ our $title = "Milsko GUI Toolkit Documentation";
our @pathlist = ("include"); our @pathlist = ("include");
our @notes = ("warning", "unsure", "note"); our @notes = ("warning", "unsure", "note");
our @files = ();
our %files_sections = ();
sub sentence { sub sentence {
my $str = $_[0]; my $str = $_[0];
$str =~ s/([^\.])$/\1./g; $str =~ s/([^\.])$/\1./g;
@@ -40,6 +43,15 @@ sub arguments {
return $out; return $out;
} }
sub replace_special {
my $ret = $_[0];
$ret =~ s/[\r\n]+//g;
$ret =~ s/[^A-Za-z0-9_]/_/g;
return $ret;
}
sub scan_dir { sub scan_dir {
my ($first, $path) = @_; my ($first, $path) = @_;
$path =~ s/\/+$//g; $path =~ s/\/+$//g;
@@ -64,6 +76,7 @@ sub scan_dir {
my %kv = (); my %kv = ();
my %param = (); my %param = ();
my @paramlist = (); my @paramlist = ();
my $current = "";
print(STDERR "$path is a file\n"); print(STDERR "$path is a file\n");
open(IN, "<", "$path"); open(IN, "<", "$path");
@@ -77,7 +90,7 @@ sub scan_dir {
} }
if ($out) { if ($out) {
my $para = "p"; my $para = "dt";
my $brief = $kv{brief} or ""; my $brief = $kv{brief} or "";
$brief = sentence($brief); $brief = sentence($brief);
@@ -93,16 +106,37 @@ sub scan_dir {
next; next;
} }
if (!$file && defined($kv{brief})) { if (!$file && defined($kv{brief})) {
my $id = "";
my $sl = "";
my $attr = "";
$para = "dd"; $para = "dd";
$l =~ s/[ \t]*\\$//g; $l =~ s/[ \t]+/ /g;
$l =~ s/[ \t]*(?:;|\{.+)[ \t]*$/;/g; $l =~ s/[ ]*\\$//g;
$l =~ s/[ ]*(?:;|\{.+)[ ]*$/;/g;
if (!($l =~ /^#/)) { if (!($l =~ /^#/)) {
$l =~ s/\(([^\)]+)\)/arguments($1)/ge; $l =~ s/\(([^\)]+)\)/arguments($1)/ge;
} }
out("<pre><code>$l</code></pre>"); $sl = $l;
$sl =~ s/\n//g;
$sl =~ s/^.+[ \t]+([^ ]+)[ \t]*\(.+\);?$/\1/g;
$sl =~ s/^.+[ \t]+([^ ]+);$/\1/g;
$id = replace_special($current . "__" . $sl);
$attr = " id=\"$id\"";
if (!defined($files_sections{ replace_special($current) }))
{
@{ $files_sections{ replace_special($current) } } = ();
}
push(@{ $files_sections{ replace_special($current) } },
$sl);
out("<pre$attr><code>$l</code></pre>");
} }
out("<dl>");
out("<$para>"); out("<$para>");
out(" $brief"); out(" $brief");
out("</$para>"); out("</$para>");
@@ -135,6 +169,7 @@ sub scan_dir {
out(" " . sentence($kv{return})); out(" " . sentence($kv{return}));
out("</dd>"); out("</dd>");
} }
out("</dl>");
out("<hr>"); out("<hr>");
} }
elsif ($l =~ /^([ \t]*)\/\*\!/) { elsif ($l =~ /^([ \t]*)\/\*\!/) {
@@ -155,11 +190,15 @@ sub scan_dir {
$kv{$1} = $2; $kv{$1} = $2;
if ($1 eq "file") { if ($1 eq "file") {
if (!$has_file) { if (!$has_file) {
out("<h2 align=\"center\">$2</h2>"); out( "<h2 align=\"center\" id=\""
. replace_special($2)
. "\">$2</h2>");
push(@files, $2);
} }
$file = 1; $file = 1;
$has_file = 1; $has_file = 1;
$current = $2;
} }
elsif ($1 eq "param") { elsif ($1 eq "param") {
my $p = $2; my $p = $2;
@@ -182,10 +221,34 @@ out(" </head>");
out(" <body>"); out(" <body>");
out(" <h1 align=\"center\">$title</h1>"); out(" <h1 align=\"center\">$title</h1>");
out(" <hr>"); out(" <hr>");
out(" <h2 align=\"center\">Table of Contents</h2>");
my $old = $html;
$html = "";
foreach my $f (@pathlist) { foreach my $f (@pathlist) {
scan_dir($f, $f); scan_dir($f, $f);
} }
my $stuff = $html;
$html = $old;
out("<dl>");
foreach my $f (@files) {
out("<dt>");
out(" <a href=\"#" . replace_special($f) . "\">$f</a>");
out("</dt>");
foreach my $sect (@{ $files_sections{ replace_special($f) } }) {
out("<dd>");
out( " <a href=\"#"
. replace_special($f . "__" . $sect)
. "\">$sect</a>");
out("</dd>");
}
}
out("</dl>");
out("<hr>");
$html = $html . $stuff;
out(" </body>"); out(" </body>");
out("</html>"); out("</html>");