* graphics/nxterm/nxterm.h
*
* SPDX-License-Identifier: Apache-2.0
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __GRAPHICS_NXTERM_NXTERM_H
#define __GRAPHICS_NXTERM_NXTERM_H
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <nuttx/mutex.h>
#include <nuttx/spinlock.h>
#include <nuttx/fs/fs.h>
#include <nuttx/nx/nx.h>
#include <nuttx/nx/nxtk.h>
#include <nuttx/nx/nxfonts.h>
#include <nuttx/nx/nxterm.h>
* Pre-processor Definitions
****************************************************************************/
#define BMFLAGS_NOGLYPH (1 << 0)
#define BM_ISSPACE(bm) (((bm)->flags & BMFLAGS_NOGLYPH) != 0)
#define NX_DEVNAME_FORMAT "/dev/nxterm%d"
#define NX_DEVNAME_SIZE 16
#define NO_HOLDER (INVALID_PROCESS_ID)
#define VT100_MAX_SEQUENCE 3
* Public Types
****************************************************************************/
enum nxterm_vt100state_e
{
VT100_NOT_CONSUMED = 0,
VT100_CONSUMED,
VT100_PROCESSED,
VT100_ABORT
};
struct nxterm_state_s;
struct nxterm_operations_s
{
int (*fill)(FAR struct nxterm_state_s *priv,
FAR const struct nxgl_rect_s *rect,
nxgl_mxpixel_t wcolor[CONFIG_NX_NPLANES]);
#ifndef CONFIG_NX_WRITEONLY
int (*move)(FAR struct nxterm_state_s *priv,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxgl_point_s *offset);
#endif
int (*bitmap)(FAR struct nxterm_state_s *priv,
FAR const struct nxgl_rect_s *dest,
FAR const void *src[CONFIG_NX_NPLANES],
FAR const struct nxgl_point_s *origin,
unsigned int stride);
};
struct nxterm_bitmap_s
{
uint8_t code;
uint8_t flags;
struct nxgl_point_s pos;
};
struct nxterm_state_s
{
FAR const struct nxterm_operations_s *ops;
FAR void *handle;
struct nxterm_window_s wndo;
mutex_t lock;
#ifdef CONFIG_DEBUG_GRAPHICS
pid_t holder;
#endif
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
bool unlinked;
uint8_t orefs;
#endif
uint8_t minor;
uint8_t fheight;
uint8_t fwidth;
uint8_t spwidth;
uint16_t maxchars;
uint16_t nchars;
struct nxgl_point_s fpos;
char seq[VT100_MAX_SEQUENCE];
uint8_t nseq;
FCACHE fcache;
struct nxterm_bitmap_s cursor;
struct nxterm_bitmap_s bm[CONFIG_NXTERM_MXCHARS];
#ifdef CONFIG_NXTERM_NXKBDIN
sem_t waitsem;
uint8_t nwaiters;
uint8_t head;
uint8_t tail;
uint8_t rxbuffer[CONFIG_NXTERM_KBDBUFSIZE];
* driver events. The 'struct pollfd' reference for each open is also
* retained in the f_priv field of the 'struct file'.
*/
FAR struct pollfd *fds[CONFIG_NXTERM_NPOLLWAITERS];
#endif
spinlock_t spinlock;
};
* Public Data
****************************************************************************/
extern const struct file_operations g_nxterm_drvrops;
* Public Function Prototypes
****************************************************************************/
FAR struct nxterm_state_s *
nxterm_register(NXTERM handle,
FAR struct nxterm_window_s *wndo,
FAR const struct nxterm_operations_s *ops,
int minor);
#ifndef CONFIG_DISABLE_PSEUDOFS_OPERATIONS
void nxterm_unregister(FAR struct nxterm_state_s *priv);
#endif
#ifdef CONFIG_NXTERM_NXKBDIN
ssize_t nxterm_read(FAR struct file *filep, FAR char *buffer, size_t len);
int nxterm_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup);
#endif
void nxterm_redraw(NXTERM handle, FAR const struct nxgl_rect_s *rect,
bool more);
#ifdef CONFIG_NXTERM_NXKBDIN
void nxterm_kbdin(NXTERM handle, FAR const uint8_t *buffer, uint8_t buflen);
#endif
int nxterm_resize(NXTERM handle, FAR const struct nxgl_size_s *size);
enum nxterm_vt100state_e nxterm_vt100(FAR struct nxterm_state_s *priv,
char ch);
void nxterm_home(FAR struct nxterm_state_s *priv);
void nxterm_clear(FAR struct nxterm_state_s *priv);
void nxterm_newline(FAR struct nxterm_state_s *priv);
FAR const
struct nxterm_bitmap_s *nxterm_addchar(FAR struct nxterm_state_s *priv,
uint8_t ch);
int nxterm_hidechar(FAR struct nxterm_state_s *priv,
FAR const struct nxterm_bitmap_s *bm);
int nxterm_backspace(FAR struct nxterm_state_s *priv);
void nxterm_fillchar(FAR struct nxterm_state_s *priv,
FAR const struct nxgl_rect_s *rect,
FAR const struct nxterm_bitmap_s *bm);
void nxterm_putc(FAR struct nxterm_state_s *priv, uint8_t ch);
void nxterm_showcursor(FAR struct nxterm_state_s *priv);
void nxterm_hidecursor(FAR struct nxterm_state_s *priv);
void nxterm_scroll(FAR struct nxterm_state_s *priv, int scrollheight);
#endif