added bindings to ioctl() with TIOCGWINSZ and TIOCSWINSZ
This commit is contained in:
parent
1ccfa8dccc
commit
ccd32b461f
35
c/ncurses.c
35
c/ncurses.c
|
@ -2,6 +2,8 @@
|
||||||
#include "scheme48.h"
|
#include "scheme48.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
//Makros zum Ein- und Auspacken von Zeigern
|
//Makros zum Ein- und Auspacken von Zeigern
|
||||||
#define curses_enter_window(w) s48_enter_integer((long) w)
|
#define curses_enter_window(w) s48_enter_integer((long) w)
|
||||||
#define curses_extract_window(w) (WINDOW*) s48_extract_integer(w)
|
#define curses_extract_window(w) (WINDOW*) s48_extract_integer(w)
|
||||||
|
@ -2080,7 +2082,35 @@ s48_value scsh_clear(void)
|
||||||
return S48_UNSPECIFIC;
|
return S48_UNSPECIFIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s48_value scsh_get_term_window_size(s48_value fd)
|
||||||
|
{
|
||||||
|
struct winsize size;
|
||||||
|
|
||||||
|
if (ioctl(s48_extract_fixnum(fd), TIOCGWINSZ, (char *) &size) < 0)
|
||||||
|
return S48_FALSE;
|
||||||
|
else
|
||||||
|
return s48_list_4(s48_enter_fixnum(size.ws_row),
|
||||||
|
s48_enter_fixnum(size.ws_col),
|
||||||
|
s48_enter_fixnum(size.ws_xpixel),
|
||||||
|
s48_enter_fixnum(size.ws_ypixel));
|
||||||
|
}
|
||||||
|
|
||||||
|
s48_value scsh_set_term_window_size(s48_value fd, s48_value row,
|
||||||
|
s48_value col, s48_value xpixel,
|
||||||
|
s48_value ypixel)
|
||||||
|
{
|
||||||
|
struct winsize size;
|
||||||
|
|
||||||
|
size.ws_row = (unsigned short) s48_extract_fixnum(row);
|
||||||
|
size.ws_col = (unsigned short) s48_extract_fixnum(col);
|
||||||
|
size.ws_xpixel = (unsigned short) s48_extract_fixnum(xpixel);
|
||||||
|
size.ws_ypixel = (unsigned short) s48_extract_fixnum(ypixel);
|
||||||
|
|
||||||
|
if (ioctl(s48_extract_fixnum(fd), TIOCSWINSZ, (char *) &size) < 0)
|
||||||
|
return S48_TRUE;
|
||||||
|
else
|
||||||
|
return S48_FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void s48_init_ncurses(void)
|
void s48_init_ncurses(void)
|
||||||
{
|
{
|
||||||
|
@ -2285,7 +2315,6 @@ void s48_init_ncurses(void)
|
||||||
S48_EXPORT_FUNCTION(scsh_refresh);
|
S48_EXPORT_FUNCTION(scsh_refresh);
|
||||||
S48_EXPORT_FUNCTION(scsh_clear);
|
S48_EXPORT_FUNCTION(scsh_clear);
|
||||||
|
|
||||||
|
S48_EXPORT_FUNCTION(scsh_get_term_window_size);
|
||||||
|
S48_EXPORT_FUNCTION(scsh_set_term_window_size);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,7 +366,10 @@
|
||||||
input
|
input
|
||||||
print-command-buffer
|
print-command-buffer
|
||||||
cursor-right-pos
|
cursor-right-pos
|
||||||
make-buffer-welcome))
|
make-buffer-welcome
|
||||||
|
|
||||||
|
get-terminal-window-size
|
||||||
|
set-terminal-window-size!))
|
||||||
|
|
||||||
(define-structure ncurses ncurses-interface
|
(define-structure ncurses ncurses-interface
|
||||||
(open scheme-with-scsh
|
(open scheme-with-scsh
|
||||||
|
@ -375,7 +378,7 @@
|
||||||
define-record-types
|
define-record-types
|
||||||
conditions
|
conditions
|
||||||
signals
|
signals
|
||||||
tty-debug
|
; tty-debug
|
||||||
handle)
|
handle)
|
||||||
(files ncurses
|
(files ncurses
|
||||||
ncurses-constants
|
ncurses-constants
|
||||||
|
|
|
@ -1595,4 +1595,16 @@
|
||||||
(wmove win y (- x 1))
|
(wmove win y (- x 1))
|
||||||
(wrefresh win)))))))
|
(wrefresh win)))))))
|
||||||
|
|
||||||
|
(import-lambda-definition get-terminal-window-size/internal
|
||||||
|
(file-descriptor)
|
||||||
|
"scsh_get_term_window_size")
|
||||||
|
|
||||||
|
(define (get-terminal-window-size file-descriptor)
|
||||||
|
(apply values
|
||||||
|
(get-terminal-window-size/internal file-descriptor)))
|
||||||
|
|
||||||
|
(import-lambda-definition set-terminal-window-size!
|
||||||
|
(file-descriptor rows columns x-pixels y-pixels)
|
||||||
|
"scsh_set_term_window_size")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue