summary refs log tree commit diff stats
path: root/config.h
diff options
context:
space:
mode:
authorkaa <kaa@laptosh.my.domain>2023-06-23 11:56:56 -0700
committerkaa <kaa@laptosh.my.domain>2023-06-23 11:56:56 -0700
commit09819bcd940492c8ccc48284880f8bc652a2845a (patch)
tree89f5425d6907b111afd74142866440fba9bced0c /config.h
downloadhyp-1.0.tar.gz
Initial. 1.0
Diffstat (limited to 'config.h')
-rw-r--r--config.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/config.h b/config.h
new file mode 100644
index 0000000..8d0cd9f
--- /dev/null
+++ b/config.h
@@ -0,0 +1,20 @@
+#define MAXWLEN 64
+#define MINWLEN 4
+
+/* Tags whose contents are searched for hyphenation. */
+char *taglist[] = {
+	"p",
+	"li",
+	/* A pointer array needs a sentinel value
+	in order to be enumerated through. */
+	"\0"
+};
+
+/* Words containing any of these characters
+ are skipped. */
+char *skip = "&/-=~";
+
+/* Should the dictionary of hyphenation patterns be in
+a location other than the one specified here, replace this
+with the valid location. */
+char *dictfile = "/usr/local/share/hyphen/hyph_en_US.dic";
34'>134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997
'\" t
.\" Automatically generated by Pandoc 3.6.4
.\"
.TH "cha\-api" "7" "" "" "Chawan\[cq]s command API"
.SH Chawan\[cq]s command API
As described in \f[B]cha\-config\f[R](5), keypress combinations can be
bound to actions.
.PP
An action can be either a JavaScript expression, or a command defined in
the \f[CR][cmd]\f[R] section of config.toml.
For example, the following works:
.IP
.EX
gpn = \[aq]n => pager.alert(n)\[aq] # e.g. 2gpn prints \[ga]2\[aq] to the status line
.EE
.PP
Note however, that JavaScript functions must be called with an
appropriate \f[CR]this\f[R] value.
Unfortunately, this also means that the following does not work:
.IP
.EX
gpn = \[aq]pager.alert\[aq] # broken!!!
.EE
.PP
To work around this limitation, actions have to wrap the target function
in a closure, as above.
However, this has very poor reusability; for more complex actions, you
would have to copy and paste the entire function every time you re\-bind
it or call it from a different function.
.PP
To fix this, it is possible to define a command in the \f[CR][cmd]\f[R]
section:
.IP
.EX
\f[B][cmd.my.namespace]\f[R]
showNumber = \[aq]n => pager.alert(n)\[aq]
.EE
.PP
\f[CR]my.namespace\f[R] can be anything you want; it is to avoid
collisions when including multiple configs.
Avoid setting it to \f[CR]pager\f[R] or \f[CR]line\f[R], because these
are used by the default config.
.PP
Now you can call \f[CR]cmd.my.namespace.showNumber()\f[R] from any other
function, or just include it in an action:
.IP
.EX
\[aq]gpn\[aq] = \[aq]cmd.my.namespace.showNumber\[aq]
.EE
.SS Interfaces
.SS Client
The global object (\f[CR]globalThis\f[R]) implements the
\f[CR]Client\f[R] interface.
Documented functions of this are:
.PP
.TS
tab(@);
lw(28.0n) lw(38.5n) lw(3.5n).
T{
Property
T}@T{
Description
T}@T{
T}
_
T{
\f[CR]quit()\f[R]
T}@T{
Exit the browser.
T}@T{
T}
_
T{
\f[CR]suspend()\f[R]
T}@T{
Temporarily suspend the browser, by delivering the client process a
SIGTSTP signal.
Note: this suspends the entire process group.
T}@T{
T}
_
T{
\f[CR]readFile(path)\f[R]
T}@T{
Read a file at \f[CR]path\f[R].
Returns the file\[cq]s content as a string, or null if the file does not
exist.
T}@T{
T}
_
T{
\f[CR]writeFile(path, content)\f[R]
T}@T{
Write \f[CR]content\f[R] to the file at \f[CR]path\f[R].
Throws a TypeError if this failed for whatever reason.
T}@T{
T}
_
T{
\f[CR]getenv(name, fallback = null)\f[R]
T}@T{
Get an environment variable by \f[CR]name\f[R].
Returns \f[CR]fallback\f[R] if the variable does not exist.
T}@T{
T}
_
T{
\f[CR]setenv(name, value)\f[R]
T}@T{
Set an environment variable by \f[CR]name\f[R].
Throws a type error if the operation failed (e.g.\ because the
variable\[cq]s size exceeded an OS\-specified limit.)
T}@T{
T}
_
T{
\f[CR]pager\f[R]
T}@T{
The pager object.
Implements \f[CR]Pager\f[R], as described below.
T}@T{
T}
_
T{
\f[CR]line\f[R]
T}@T{
The line editor.
Implements \f[CR]LineEdit\f[R], as described below.
T}@T{
T}
_
T{
\f[CR]config\f[R]
T}@T{
The config object.
A currently incomplete interface for retrieving and setting
configuration options.
In general, names are the same as in config.toml, except all
\f[CR]\-\f[R] (ASCII hyphen) characters are stripped and the next
character is upper\-cased.
e.g.\ \f[CR]external.cgi\-dir\f[R] can be queried as
\f[CR]config.external.cgiDir\f[R], etc.
Setting individual options sometimes works, but sometimes they do not
get propagated as expected.
Consider this an experimental API.
Currently, \f[CR]siteconf\f[R], \f[CR]protocol\f[R] and
\f[CR]omnirule\f[R] values are not exposed to JS.
The configuration directory itself can be queried as
\f[CR]config.dir\f[R].
T}@T{
T}
.TE
.PP
\f[CR]Client\f[R] also implements various web standards normally
available on the \f[CR]Window\f[R] object on websites, e.g.\ fetch().
Note however that it does \f[I]not\f[R] give access to JS objects in
buffers, so e.g.\ \f[CR]globalThis.document\f[R] is not available.
.SS Pager
\f[CR]Pager\f[R] is a separate interface from \f[CR]Client\f[R] that
gives access to the pager (i.e.\ browser chrome).
It is accessible as \f[CR]globalThis.pager\f[R], or simply
\f[CR]pager\f[R].
.PP
Following properties (functions/getters) are defined by
\f[CR]Pager\f[R]:
.PP
.TS
tab(@);
lw(28.0n) lw(38.5n) lw(3.5n).
T{
Property
T}@T{
Description
T}@T{
T}
_
T{
\f[CR]load(url)\f[R]
T}@T{
Put the specified address into the URL bar, and optionally load it.
Note that this performs auto\-expansion of URLs, so Chawan will expand
any matching omni\-rules (e.g.\ search), try to open schemeless URLs
with the default scheme/local files, etc.
Opens a prompt with the current URL when no parameters are specified;
otherwise, the string passed is displayed in the prompt.
If this string ends with a newline
(e.g.\ \f[CR]pager.load(\[dq]about:chawan\[rs]n\[dq])\f[R]), the URL is
loaded directly.
T}@T{
T}
_
T{
\f[CR]loadSubmit(url)\f[R]
T}@T{
Act as if \f[CR]url\f[R] had been input into the address bar.
Same as \f[CR]pager.load(url + \[dq]\[rs]n\[dq])\f[R].
T}@T{
T}
_
T{
\f[CR]gotoURL(url, options = {replace: null, contentType: null, save: false})\f[R]
T}@T{
Go to the specified URL immediately (without a prompt).
This differs from \f[CR]loadSubmit\f[R] in that it loads the exact URL
as passed (no prepending https, etc.)
When \f[CR]replace\f[R] is set, the new buffer may replace the old one
if it loads successfully.
When \f[CR]contentType\f[R] is set, the new buffer\[cq]s content type is
forcefully set to that string.
When \f[CR]save\f[R] is true, the user is prompted to save the resource
instead of displaying it in a buffer.
T}@T{
T}
_
T{
\f[CR]nextBuffer()\f[R], \f[CR]prevBuffer()\f[R],
\f[CR]nextSiblingBufer()\f[R], \f[CR]prevSiblingBuffer()\f[R],
\f[CR]parentBuffer()\f[R]
T}@T{
Traverse the buffer tree.
\f[CR]nextBuffer()\f[R], \f[CR]prevBuffer()\f[R] do a depth\-first
traversal; \[ga]\f[CR]nextSiblingBufer()\f[R],
\f[CR]prevSiblingBuffer()\f[R] cycle through siblings, and
\f[CR]parentBuffer()\f[R] returns to the parent.
T}@T{
T}
_
T{
\f[CR]dupeBuffer()\f[R]
T}@T{
Duplicate the current buffer by loading its source to a new buffer.
T}@T{
T}
_
T{
\f[CR]discardBuffer(buffer = pager.buffer, dir = pager.navDirection)\f[R]
T}@T{
Discard \f[CR]buffer\f[R], then move back to the buffer opposite to
\f[CR]dir\f[R].
Possible values of \f[CR]dir\f[R] are: \[lq]prev\[rq], \[lq]next\[rq],
\[lq]prev\-sibling\[rq], \[lq]next\-sibling\[rq], \[lq]parent\[rq],
\[lq]first\-child\[rq], \[lq]any\[rq].
T}@T{
T}
_
T{
\f[CR]discardTree()\f[R]
T}@T{
Discard all child buffers of the current buffer.
T}@T{
T}
_
T{
\f[CR]reload()\f[R]
T}@T{
Open a new buffer with the current buffer\[cq]s URL, replacing the
current buffer.
T}@T{
T}
_
T{
\f[CR]reshape()\f[R]
T}@T{
Reshape the current buffer (=render the current page anew.)
T}@T{
T}
_
T{
\f[CR]redraw()\f[R]
T}@T{
Redraw screen contents.
Useful if something messed up the display.
T}@T{
T}
_
T{
\f[CR]toggleSource()\f[R]
T}@T{
If viewing an HTML buffer, open a new buffer with its source.
Otherwise, open the current buffer\[cq]s contents as HTML.
T}@T{
T}
_
T{
\f[CR]lineInfo()\f[R]
T}@T{
Display information about the current line.
T}@T{
T}
_
T{
\f[CR]searchForward()\f[R], \f[CR]searchBackward()\f[R]
T}@T{
Search forward/backward for a string in the current buffer.
T}@T{
T}
_
T{
\f[CR]isearchForward()\f[R], \f[CR]isearchBackward()\f[R]
T}@T{
Incremental\-search forward/backward for a string, highlighting the
first result.
T}@T{
T}
_
T{
\f[CR]gotoLine(n?)\f[R]
T}@T{
Go to the line passed as the first argument.
If no arguments were specified, an input window for entering a line is
shown.
T}@T{
T}
_
T{
\f[CR]searchNext(n = 1)\f[R], \f[CR]searchPrev(n = 1)\f[R]
T}@T{
Jump to the nth next/previous search result.
T}@T{
T}
_
T{
\f[CR]peek()\f[R]
T}@T{
Display an alert message of the current URL.
T}@T{
T}
_
T{
\f[CR]peekCursor()\f[R]
T}@T{
Display an alert message of the URL or title under the cursor.
Multiple calls allow cycling through the two.
(i.e.\ by default, press u once \-> title, press again \-> URL)
T}@T{
T}
_
T{
\f[CR]showFullAlert()\f[R]
T}@T{
Show the last alert inside the line editor.
T}@T{
T}
_
T{
\f[CR]ask(prompt)\f[R]
T}@T{
Ask the user for confirmation.
Returns a promise which resolves to a boolean value indicating whether
the user responded with yes.
Can be used to implement an exit prompt like this:
\f[CR]q = \[aq]pager.ask(\[dq]Do you want to exit Chawan?\[dq]).then(x => x ? pager.quit() : void(0))\[aq]\f[R]
T}@T{
T}
_
T{
\f[CR]askChar(prompt)\f[R]
T}@T{
Ask the user for any character.
Like \f[CR]pager.ask\f[R], but the return value is a character.
T}@T{
T}
_
T{
\f[CR]extern(cmd, options = {env: { ... }, suspend: true, wait: false})\f[R]
T}@T{
Run an external command \f[CR]cmd\f[R].
By default, the \f[CR]$CHA_URL\f[R] and \f[CR]$CHA_CHARSET\f[R]
variables are set; change this using the \f[CR]env\f[R] option.
\f[CR]options.suspend\f[R] suspends the pager while the command is being
executed, and \f[CR]options.wait\f[R] makes it so the user must press a
key before the pager is resumed.
Returns true if the command exited successfully, false otherwise.
Warning: this has a bug where the output is written to stdout even if
suspend is true.
Redirect to /dev/null in the command if this is not desired.
(This will be fixed in the future.)
T}@T{
T}
_
T{
\f[CR]externCapture(cmd)\f[R]
T}@T{
Like extern(), but redirect the command\[cq]s stdout string into the
result.
null is returned if the command wasn\[cq]t executed successfully, or if
the command returned a non\-zero exit value.
T}@T{
T}
_
T{
\f[CR]externInto(cmd, ins)\f[R]
T}@T{
Like extern(), but redirect \f[CR]ins\f[R] into the command\[cq]s
standard input stream.
\f[CR]true\f[R] is returned if the command exits successfully, otherwise
the return value is \f[CR]false\f[R].
T}@T{
T}
_
T{
\f[CR]externFilterSource(cmd, buffer = null, contentType = null)\f[R]
T}@T{
Redirects the specified (or if \f[CR]buffer\f[R] is null, the current)
buffer\[cq]s source into \f[CR]cmd\f[R].
Then, it pipes the output into a new buffer, with the content type
\f[CR]contentType\f[R] (or, if \f[CR]contentType\f[R] is null, the
original buffer\[cq]s content type).
Returns \f[CR]undefined\f[R].
(It should return a promise; TODO.)
T}@T{
T}
_
T{
\f[CR]buffer\f[R]
T}@T{
Getter for the currently displayed buffer.
Returns a \f[CR]Buffer\f[R] object; see below.
T}@T{
T}
.TE
.SS Buffer
Each buffer is exposed as an object that implements the
\f[CR]Buffer\f[R] interface.
To get a reference to the currently displayed buffer, use
\f[CR]pager.buffer\f[R].
.PP
Important: there exists a quirk of questionable value on pager, where
accessing properties that do not exist on the pager will dispatch those
to the current buffer (\f[CR]pager.buffer\f[R]).
So if you see e.g.\ \f[CR]pager.url\f[R], that is actually equivalent to
\f[CR]pager.buffer.url\f[R], because \f[CR]Pager\f[R] has no
\f[CR]url\f[R] getter.
.PP
Following properties (functions/getters) are defined by
\f[CR]Buffer\f[R]:
.PP
.TS
tab(@);
lw(28.0n) lw(38.5n) lw(3.5n).
T{
Property
T}@T{
Description
T}@T{
T}
_
T{
\f[CR]cursorUp(n = 1)\f[R], \f[CR]cursorDown(n = 1)\f[R]
T}@T{
Move the cursor upwards/downwards by n lines, or if n is unspecified, by
1.
T}@T{
T}
_
T{
\f[CR]cursorLeft(n = 1)\f[R], \f[CR]cursorRight(n = 1)\f[R]
T}@T{
Move the cursor to the left/right by n cells, or if n is unspecified, by
1.
Note: \f[CR]n\f[R] right now represents cells, but really it should
represent characters.
(The difference is that right now numbered cursorLeft/cursorRight is
broken for double\-width chars.)
T}@T{
T}
_
T{
\f[CR]cursorLineBegin()\f[R], \f[CR]cursorLineEnd()\f[R]
T}@T{
Move the cursor to the first/last cell of the line.
T}@T{
T}
_
T{
\f[CR]cursorLineTextStart()\f[R]
T}@T{
Move the cursor to the first non\-blank character of the line.
T}@T{
T}
_
T{
\f[CR]cursorNextWord()\f[R], \f[CR]cursorNextViWord()\f[R],
\f[CR]cursorNextBigWord()\f[R]
T}@T{
Move the cursor to the beginning of the next word.
T}@T{
T}
_
T{
\f[CR]cursorPrevWord()\f[R], \f[CR]cursorPrevViWord()\f[R],
\f[CR]cursorPrevBigWord()\f[R]
T}@T{
Move the cursor to the end of the previous word.
T}@T{
T}
_
T{
\f[CR]cursorWordEnd()\f[R], \f[CR]cursorViWordEnd()\f[R],
\f[CR]cursorBigWordEnd()\f[R]
T}@T{
Move the cursor to the end of the current word, or if already there, to
the end of the next word.
T}@T{
T}
_
T{
\f[CR]cursorWordBegin()\f[R], \f[CR]cursorViWordBegin()\f[R],
\f[CR]cursorBigWordBegin()\f[R]
T}@T{
Move the cursor to the beginning of the current word, or if already
there, to the end of the previous word.
T}@T{
T}
_
T{
\f[CR]cursorNextLink()\f[R], \f[CR]cursorPrevLink()\f[R]
T}@T{
Move the cursor to the beginning of the next/previous clickable element.
T}@T{
T}
_
T{
\f[CR]cursorLinkNavDown(n = 1)\f[R], \f[CR]cursorLinkNavUp(n = 1)\f[R]
T}@T{
Move the cursor to the beginning of the next/previous clickable element.
Buffer scrolls pagewise, wrap to beginning/end if content is less than
one page length.
T}@T{
T}
_
T{
\f[CR]cursorNextParagraph(n = 1)\f[R],
\f[CR]cursorPrevParagraph(n = 1)\f[R]
T}@T{
Move the cursor to the beginning/end of the nth next/previous paragraph.
T}@T{
T}
_
T{
\f[CR]cursorNthLink(n = 1)\f[R]
T}@T{
Move the cursor to the nth link of the document.
T}@T{
T}
_
T{
\f[CR]cursorRevNthLink(n = 1)\f[R]
T}@T{
Move the cursor to the nth link of the document, counting backwards from
the document\[cq]s last line.
T}@T{
T}
_
T{
\f[CR]pageUp(n = 1)\f[R], \f[CR]pageDown(n = 1)\f[R],
\f[CR]pageLeft(n = 1)\f[R], \f[CR]pageRight(n = 1)\f[R]
T}@T{
Scroll up/down/left/right by n pages.
T}@T{
T}
_
T{
\f[CR]halfPageUp(n = 1)\f[R], \f[CR]halfPageDown(n = 1)\f[R],
\f[CR]halfPageLeft(n = 1)\f[R], \f[CR]halfPageRight(n = 1)\f[R]
T}@T{
Scroll up/down/left/right by n half pages.
T}@T{
T}
_
T{
\f[CR]scrollUp(n = 1)\f[R], \f[CR]scrollDown(n = 1)\f[R],
\f[CR]scrollLeft(n = 1)\f[R], \f[CR]scrollRight(n = 1)\f[R]
T}@T{
Scroll up/down/left/right by n lines.
T}@T{
T}
_
T{
\f[CR]click()\f[R]
T}@T{
Click the HTML element currently under the cursor.
T}@T{
T}
_
T{
\f[CR]cursorFirstLine()\f[R], \f[CR]cursorLastLine()\f[R]
T}@T{
Move to the first/last line in the buffer.
T}@T{
T}
_
T{
\f[CR]cursorTop()\f[R], \f[CR]cursorMiddle()\f[R],
\f[CR]cursorBottom()\f[R]
T}@T{
Move to the first/middle/bottom line on the screen.
(Equivalent to H/M/L in vi.)
T}@T{
T}
_
T{
\f[CR]lowerPage(n = this.cursory)\f[R]
T}@T{
Move cursor to line n, then scroll up so that the cursor is on the top
line on the screen.
(\f[CR]zt\f[R] in vim.)
T}@T{
T}
_
T{
\f[CR]lowerPageBegin(n = this.cursory)\f[R]
T}@T{
Move cursor to the first non\-blank character of line n, then scroll up
so that the cursor is on the top line on the screen.
(\f[CR]z<CR>\f[R] in vi.)
T}@T{
T}
_
T{
\f[CR]centerLine(n = this.cursory)\f[R]
T}@T{
Center screen around line n.\ (\f[CR]zz\f[R] in vim.)
T}@T{
T}
_
T{
\f[CR]centerLineBegin(n = this.cursory)\f[R]
T}@T{
Center screen around line n, and move the cursor to the line\[cq]s first
non\-blank character.
(\f[CR]z.\f[R] in vi.)
T}@T{
T}
_
T{
\f[CR]raisePage(n = this.cursory)\f[R]
T}@T{
Move cursor to line n, then scroll down so that the cursor is on the top
line on the screen.
(zb in vim.)
T}@T{
T}
_
T{
\f[CR]lowerPageBegin(n = this.cursory)\f[R]
T}@T{
Move cursor to the first non\-blank character of line n, then scroll up
so that the cursor is on the last line on the screen.
(\f[CR]z\[ha]\f[R] in vi.)
T}@T{
T}
_
T{
\f[CR]nextPageBegin(n = this.cursory)\f[R]
T}@T{
If n was given, move to the screen before the nth line and raise the
page.
Otherwise, go to the previous screen\[cq]s last line and raise the page.
(\f[CR]z+\f[R] in vi.)
T}@T{
T}
_
T{
\f[CR]cursorLeftEdge()\f[R], \f[CR]cursorMiddleColumn()\f[R],
\f[CR]cursorRightEdge()\f[R]
T}@T{
Move to the first/middle/last column on the screen.
T}@T{
T}
_
T{
\f[CR]centerColumn()\f[R]
T}@T{
Center screen around the current column.
T}@T{
T}
_
T{
\f[CR]findNextMark(x = this.cursorx, y = this.cursory)\f[R],
\f[CR]findPrevMark(x = this.cursorx, y = this.cursory)\f[R]
T}@T{
Find the next/previous mark after/before \f[CR]x\f[R], \f[CR]y\f[R], if
any; and return its id (or null if none were found.)
T}@T{
T}
_
T{
\f[CR]setMark(id, x = this.cursorx, y = this.cursory)\f[R]
T}@T{
Set a mark at (x, y) using the name \f[CR]id\f[R].
Returns true if no other mark exists with \f[CR]id\f[R].
If one already exists, it will be overridden and the function returns
false.
T}@T{
T}
_
T{
\f[CR]clearMark(id)\f[R]
T}@T{
Clear the mark with the name \f[CR]id\f[R].
Returns true if the mark existed, false otherwise.
T}@T{
T}
_
T{
\f[CR]gotoMark(id)\f[R]
T}@T{
If the mark \f[CR]id\f[R] exists, jump to its position and return true.
Otherwise, do nothing and return false.
T}@T{
T}
_
T{
\f[CR]gotoMarkY(id)\f[R]
T}@T{
If the mark \f[CR]id\f[R] exists, jump to the beginning of the line at
its Y position and return true.
Otherwise, do nothing and return false.
T}@T{
T}
_
T{
\f[CR]getMarkPos(id)\f[R]
T}@T{
If the mark \f[CR]id\f[R] exists, return its position as an array where
the first element is the X position and the second element is the Y
position.
If the mark does not exist, return null.
T}@T{
T}
_
T{
\f[CR]cursorToggleSelection(n = 1, opts = {selectionType: \[dq]normal\[dq]})\f[R]
T}@T{
Start a vim\-style visual selection.
The cursor is moved to the right by \f[CR]n\f[R] cells.
selectionType may be \[lq]normal\[rq] (regular selection),
\[lq]line\[rq] (line\-based selection) and \[lq]column\[rq]
(column\-based selection).
T}@T{
T}
_
T{
\f[CR]getSelectionText()\f[R]
T}@T{
Get the currently selected text.
Returns a promise, so consumers must \f[CR]await\f[R] it to get the
text.
T}@T{
T}
_
T{
\f[CR]markURL()\f[R]
T}@T{
Convert URL\-like strings to anchors on the current page.
T}@T{
T}
_
T{
\f[CR]toggleImages()\f[R]
T}@T{
Toggle display of images in this buffer.
T}@T{
T}
_
T{
\f[CR]saveLink()\f[R]
T}@T{
Save URL pointed to by the cursor.
T}@T{
T}
_
T{
\f[CR]saveSource()\f[R]
T}@T{
Save the source of this buffer.
T}@T{
T}
_
T{
\f[CR]setCursorX(x)\f[R], \f[CR]setCursorY(y)\f[R],
\f[CR]setCursorXY(x, y)\f[R], \f[CR]setCursorXCenter(x)\f[R],
\f[CR]setCursorYCenter(y)\f[R], \f[CR]setCursorXYCenter(x, y)\f[R]
T}@T{
Set the cursor position to \f[CR]x\f[R] and \f[CR]y\f[R] respectively,
scrolling the view if necessary.
Variants that end with \[lq]Center\[rq] will also center the screen
around the position if it is outside the screen.
T}@T{
T}
_
T{
\f[CR]url\f[R]
T}@T{
Getter for the buffer\[cq]s URL.
Note: this returns a \f[CR]URL\f[R] object, not a string.
T}@T{
T}
_
T{
\f[CR]hoverTitle\f[R], \f[CR]hoverLink\f[R], \f[CR]hoverImage\f[R]
T}@T{
Getter for the string representation of the element title/link/image
currently under the cursor.
Returns the empty string if no title is found.
T}@T{
T}
_
T{
\f[CR]cursorx\f[R], \f[CR]cursory\f[R]
T}@T{
The x/y position of the cursor inside the buffer.
Note that although the status line is 1\-based, these values are
0\-based.
T}@T{
T}
_
T{
\f[CR]fromx\f[R], \f[CR]fromy\f[R]
T}@T{
The x/y position of the first line displayed on the screen.
T}@T{
T}
_
T{
\f[CR]numLines\f[R]
T}@T{
The number of lines currently loaded in the buffer.
T}@T{
T}
_
T{
\f[CR]width\f[R], \f[CR]height\f[R]
T}@T{
The width and height of the buffer\[cq]s window (i.e.\ the visible part
of the canvas).
T}@T{
T}
_
T{
\f[CR]process\f[R]
T}@T{
The process ID of the buffer.
T}@T{
T}
_
T{
\f[CR]title\f[R]
T}@T{
Text from the \f[CR]title\f[R] element, or the buffer\[cq]s URL if there
is no title.
T}@T{
T}
_
T{
\f[CR]parent\f[R]
T}@T{
Parent buffer in the buffer tree.
May be null.
T}@T{
T}
_
T{
\f[CR]children\f[R]
T}@T{
Array of child buffers in the buffer tree.
T}@T{
T}
_
T{
\f[CR]select\f[R]
T}@T{
Reference to the current \f[CR]select\f[R] element\[cq]s widget, or null
if no \f[CR]select\f[R] element is open.
This object implements the \f[CR]Select\f[R] interface, which is
somewhat compatible with the \f[CR]Buffer\f[R] interface with some
exceptions.
(TODO: elaborate)
T}@T{
T}
.TE
.SS LineEdit
The line editor at the bottom of the screen is exposed to the JavaScript
context as \f[CR]globalThis.line\f[R], or simply \f[CR]line\f[R], and
implements the \f[CR]LineEdit\f[R] interface.
.PP
Note that there is no single \f[CR]LineEdit\f[R] object; a new one is
created every time the line editor is opened, and when the line editor
is closed, \f[CR]globalThis.line\f[R] simply returns \f[CR]null\f[R].
.PP
Following properties (functions/getters) are defined by
\f[CR]LineEdit\f[R]:
.PP
.TS
tab(@);
lw(28.0n) lw(38.5n) lw(3.5n).
T{
Property
T}@T{
Description
T}@T{
T}
_
T{
\f[CR]submit()\f[R]
T}@T{
Submit line.
T}@T{
T}
_
T{
\f[CR]cancel()\f[R]
T}@T{
Cancel operation.
T}@T{
T}
_
T{
\f[CR]backspace()\f[R]
T}@T{
Delete character before cursor.
T}@T{
T}
_
T{
\f[CR]delete()\f[R]
T}@T{
Delete character after cursor.
T}@T{
T}
_
T{
\f[CR]clear()\f[R]
T}@T{
Clear text before cursor.
T}@T{
T}
_
T{
\f[CR]kill()\f[R]
T}@T{
Clear text after cursor.
T}@T{
T}
_
T{
\f[CR]clearWord()\f[R]
T}@T{
Delete word before cursor.
T}@T{
T}
_
T{
\f[CR]killWord()\f[R]
T}@T{
Delete word after cursor.
T}@T{
T}
_
T{
\f[CR]backward()\f[R], \f[CR]forward()\f[R]
T}@T{
Move cursor backward/forward by one character.
T}@T{
T}
_
T{
\f[CR]nextWord()\f[R], \f[CR]prevWord()\f[R]
T}@T{
Move cursor to the next/previous word by one character.
T}@T{
T}
_
T{
\f[CR]begin()\f[R], \f[CR]end()\f[R]
T}@T{
Move cursor to the beginning/end of the line.
T}@T{
T}
_
T{
\f[CR]escape()\f[R]
T}@T{
Ignore keybindings for next character.
T}@T{
T}
_
T{
\f[CR]nextHist()\f[R], \f[CR]prevHist()\f[R]
T}@T{
Jump to the previous/next history entry.
T}@T{
T}
.TE
.SS See also
\f[B]cha\f[R](1) \f[B]cha\-config\f[R](5)