[vala/0.50] curses: Add Terminfo API set, function keycodes F(n) and minor changes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.50] curses: Add Terminfo API set, function keycodes F(n) and minor changes
- Date: Fri, 23 Oct 2020 14:19:33 +0000 (UTC)
commit 886891f3a6f5e2238a1f764bc0e81e1c0d3081ed
Author: Reuben Thomas <rrt sc3d org>
Date: Wed Oct 21 21:59:41 2020 +0200
curses: Add Terminfo API set, function keycodes F(n) and minor changes
Some terminfo-related API were already bound (mvcur, vidattr, vidputs);
move these all together, and add missing symbols (all from term.h).
Bind the “F(n)” macro for function key codes.
Annotate VidputsPutcFunc for correct C generation.
Add attribute A_ITALIC (ncurses extension).
vapi/curses.vapi | 61 +++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 52 insertions(+), 9 deletions(-)
---
diff --git a/vapi/curses.vapi b/vapi/curses.vapi
index 6dcc78e43..022ee656d 100644
--- a/vapi/curses.vapi
+++ b/vapi/curses.vapi
@@ -1,4 +1,4 @@
-/* curses.vala
+/* curses.vapi
*
* Copyright (c) 2007 Ed Schouten <ed fxq nl>
* All rights reserved.
@@ -357,7 +357,6 @@ namespace Curses {
public int mvaddnstr(int y, int x, string str, int n);
public int mvaddstr(int y, int x, string str);
public int mvchgat(int y, int x, int n, ulong attr, short color);
- public int mvcur(int oldrow, int oldcol, int newrow, int newcol);
public int mvdelch(int y, int x);
public int mvgetch(int y, int x);
public int mvgetnstr(int y, int x, string str, int n);
@@ -429,23 +428,63 @@ namespace Curses {
public int typeahead(int fd);
public int ungetch(int ch);
public void use_env(bool bf);
- public int vidattr(ulong attrs);
- public delegate int VidputsPutcFunc(char ch);
- public int vidputs(ulong attrs, VidputsPutcFunc putc);
public int vline(ulong ch, int n);
+ // curses interface to terminfo (term.h)
+ [CCode (cname = "TERMINAL", cheader_filename = "term.h", has_type_id = false)]
+ public struct Terminal {
+ [CCode (cname = "set_curterm")]
+ public unowned Terminal? set_cur();
+ [CCode (cname = "del_curterm")]
+ public int del_cur();
+ }
+ public static Terminal? cur_term;
+ [CCode (cheader_filename = "term.h")]
+ public int setupterm(string? term, int filedes, out int errret);
+ [CCode (cheader_filename = "term.h")]
+ public int setterm(string? term);
+ [CCode (cheader_filename = "term.h")]
+ public int restartterm(string? term, int filedes, out int errret);
+
+ [CCode (has_typedef = false, has_target = false)]
+ public delegate int VidputsPutcFunc([CCode (type = "int")] char c);
+
+ [CCode (cheader_filename = "term.h")]
+ namespace TermInfo {
+ [CCode (cname = "tputs")]
+#if POSIX
+ public int puts(string str, int affcnt = 1, VidputsPutcFunc putc = (c) => Posix.stdout.putc
(c));
+#else
+ public int puts(string str, int affcnt = 1, VidputsPutcFunc putc = (c) => GLib.stdout.putc
(c));
+#endif
+ [CCode (cname = "tigetflag")]
+ public int getflag(string capname);
+ [CCode (cname = "tigetnum")]
+ public int getnum(string capname);
+ [CCode (cname = "tigetstr")]
+ public unowned string? getstr(string capname);
+ [CCode (cname = "tiparm")]
+ public unowned string parm(string capname, ...);
+ }
+
+ public int vidputs(ulong attrs, VidputsPutcFunc putc);
+ public int vidattr(ulong attrs);
+
+ public int mvcur(int oldrow, int oldcol, int newrow, int newcol);
+
[CCode (cprefix = "A_", has_type_id = false)]
public enum Attribute {
NORMAL, ATTRIBUTES, CHARTEXT, COLOR, STANDOUT,
UNDERLINE, REVERSE, BLINK, DIM, BOLD, ALTCHARSET, INVIS,
- PROTECT, HORIZONTAL, LEFT, LOW, RIGHT, TOP, VERTICAL
+ PROTECT, HORIZONTAL, LEFT, LOW, RIGHT, TOP, VERTICAL,
+ ITALIC // ITALIC is an ncurses extension
}
[CCode (has_type_id = false)]
public enum Key {
CODE_YES, MIN, BREAK, SRESET, RESET, DOWN, UP, LEFT,
- RIGHT, HOME, BACKSPACE, F0, /* XXX F(n), */ DL, IL, DC,
- IC, EIC, CLEAR, EOS, EOL, SF, SR, NPAGE, PPAGE, STAB,
+ RIGHT, HOME, BACKSPACE, F0, DL, IL, DC, IC, EIC,
+ CLEAR, EOS, EOL, SF, SR, NPAGE, PPAGE, STAB,
CTAB, CATAB, ENTER, PRINT, LL, A1, A3, B2, C1, C3, BTAB,
BEG, CANCEL, CLOSE, COMMAND, COPY, CREATE, END, EXIT,
FIND, HELP, MARK, MESSAGE, MOVE, NEXT, OPEN, OPTIONS,
@@ -455,7 +494,11 @@ namespace Curses {
SHOME, SIC, SLEFT, SMESSAGE, SMOVE, SNEXT, SOPTIONS,
SPREVIOUS, SPRINT, SREDO, SREPLACE, SRIGHT, SRSUME,
SSAVE, SSUSPEND, SUNDO, SUSPEND, UNDO, MOUSE, RESIZE,
- EVENT, MAX
+ EVENT, MAX;
+
+ public static int F (int n) {
+ return F0 + n;
+ }
}
/* TODO: mouse + wide char support */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]