ncpty¶
An NCurses pseudoterminal library.
API still under initial development.
API¶
-
struct ncpty_t¶
- file ncpty.h
- #include <ncurses.h>#include <panel.h>#include <sys/types.h>#include <vterm.h>
Public header for ncpty - the curses pseudoterminal.
Functions
-
struct ncpty_t *ncpty_new(PANEL *panel)¶
Allocate a new ncpty object assigned with an ncurses
PANEL.The pseudoterminal assumes responsibility for the
WINDOWuntil a call toncpty_freeand any existing pointers to theWINDOWshould be considered invalid.- Parameters:
panel – [in] ncurses panel to be used by the pseudoterminal process
- Returns:
a newly allocated
ncpty_tif successful, otherwise returnsNULL
-
void ncpty_free(struct ncpty_t *pty)¶
Deallocate an ncpty object.
- Parameters:
pty – [in] ncpty object to destroy
-
int ncpty_execvp(struct ncpty_t *pty, const char *file, char *const argv[])¶
Create a pseudoterminal, fork, exec and attach a child process to the child-side.
If this call fails for any reason, the ncpty object is left in a definite state.
- Parameters:
pty – [out] ncpty object device
file – [in] filename of file to executed (will search on $PATH)
argv – [in] array of null-terminated string arguments, terminated by a null pointer
- Returns:
0 for success, -1 for execvp error. errno is set to indicate the specific error encountered.
-
bool ncpty_status(struct ncpty_t *pty, int *exit_code)¶
Check if child process controlled by ncpty object has exited.
- Parameters:
pty – [in] ncpty object
exit_code – [out]
- Returns:
trueif process is still running,falseotherwise
-
void ncpty_exit(int exit_code)¶
Exit program.
Convenience function. Uses
exit_cursesif built with ncurses 6.2.20191214 or later.- Parameters:
exit_code – [in]
-
struct ncpty_t *ncpty_new(PANEL *panel)¶
- file banner.c
- #include <stdio.h>#include <string.h>#include <sys/stat.h>#include <sys/types.h>#include <sys/wait.h>#include <unistd.h>#include “ncpty.h”
Simple example of ncpty use that wraps a terminal in header and footer banners.
- file ncpty.c
- #include “ncpty.h”#include <curses.h>#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <sys/ioctl.h>#include <sys/wait.h>#include <termios.h>#include <unistd.h>
Functions
-
struct ncpty_t *ncpty_new(PANEL *panel)
Allocate a new ncpty object assigned with an ncurses
PANEL.The pseudoterminal assumes responsibility for the
WINDOWuntil a call toncpty_freeand any existing pointers to theWINDOWshould be considered invalid.- Parameters:
panel – [in] ncurses panel to be used by the pseudoterminal process
- Returns:
a newly allocated
ncpty_tif successful, otherwise returnsNULL
-
void ncpty_free(struct ncpty_t *pty)
Deallocate an ncpty object.
- Parameters:
pty – [in] ncpty object to destroy
-
int ncpty_execvp(struct ncpty_t *pty, const char *file, char *const argv[])
Create a pseudoterminal, fork, exec and attach a child process to the child-side.
If this call fails for any reason, the ncpty object is left in a definite state.
- Parameters:
pty – [out] ncpty object device
file – [in] filename of file to executed (will search on $PATH)
argv – [in] array of null-terminated string arguments, terminated by a null pointer
- Returns:
0 for success, -1 for execvp error. errno is set to indicate the specific error encountered.
-
bool ncpty_status(struct ncpty_t *pty, int *exit_code)
Check if child process controlled by ncpty object has exited.
- Parameters:
pty – [in] ncpty object
exit_code – [out]
- Returns:
trueif process is still running,falseotherwise
-
void ncpty_exit(int exit_code)
Exit program.
Convenience function. Uses
exit_cursesif built with ncurses 6.2.20191214 or later.- Parameters:
exit_code – [in]
-
struct ncpty_t *ncpty_new(PANEL *panel)
- file ncpty_test.c
- #include “greatest.h”#include “ncpty.h”#include <sys/resource.h>#include <sys/queue.h>#include <sys/time.h>
- dir src/bin
- dir include
- dir src/lib
- dir src
- dir src/test