aboutsummaryrefslogtreecommitdiff
path: root/teco.h
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2025-04-26 04:31:00 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2025-04-26 04:31:00 +0300
commitb5325e00c402ec18034da4b4a4aaaefa87bb1fef (patch)
treeee833a25466695ab71065e53b536fde54d83302e /teco.h
parent96e10b90b1bbd85716df314272e8cad64e256f9d (diff)
downloadvideoteco-fork-b5325e00c402ec18034da4b4a4aaaefa87bb1fef.tar.gz
unsigned long is the base type for buffer positions now
* This allows handling files >64kb even on 16-bit DOS. * A few flags fields could be squashed into bitfields. * The buffer overview (0EB) has been adapted for DOS. We can only show the total amount of allocated memory (as by tecmem.c) for the time being. Unfortunately, we don't have a total amount of available memory since _memavl() is for small data models and the sbrk() apparently doesn't grow.
Diffstat (limited to 'teco.h')
-rw-r--r--teco.h536
1 files changed, 271 insertions, 265 deletions
diff --git a/teco.h b/teco.h
index e22dd10..42d04ce 100644
--- a/teco.h
+++ b/teco.h
@@ -45,16 +45,257 @@
#define VMINOR 0
#define AUTO_DATE "$Date: 2007/12/10 22:13:07 $"
+/*
+ * Immediately start insertion after the first escape in FS.
+ */
+#define INTERACTIVE_FS
+
+/**
+ * We define unix except for the really different operating systems, like
+ * vms. It lets us write our own version of functions which simply do not
+ * exist outside of unix.
+ */
+#if !defined(VMS) && !defined(MSDOS)
+#define UNIX
+#define JOB_CONTROL
+#endif
+
+/*
+ * Include Files From GNU Autoconf/Autoheader
+ *
+ * FIXME: The Autoconf build system does not pass down -DHAVE_CONFIG_H.
+ * This should be fixed by rewriting it as the original sources
+ * are missing.
+ */
+//#ifdef HAVE_CONFIG_H
+#ifndef __WATCOMC__
+#include "config.h"
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+/*
+ * sys/filio.h has the FIONREAD definition
+ */
+#ifdef HAVE_SYS_FILIO_H
+#include <sys/filio.h>
+#endif
+#ifdef FIONREAD
+#define HAS_FIONREAD
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+#endif
+
+#if HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#else
+#if HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#endif
+
+#if HAVE_STRING_H
+# if !STDC_HEADERS && HAVE_MEMORY_H
+# include <memory.h>
+# endif
+# include <string.h>
+# if !HAVE_STRCHR
+# if !defined(strchr)
+# define strchr index
+# endif
+# if !defined(strrchr)
+# define strrchr rindex
+# endif
+# endif
+#endif
+
+/* on SGI this gets us BZERO */
+#if HAVE_STRINGS_H
+#include <strings.h>
+#endif
+
+#if HAVE_INTTYPES_H
+#include <inttypes.h>
+#else
+#if HAVE_STDINT_H
+#include <stdint.h>
+#endif
+#endif
+
#if HAVE_STDIO_H
#include <stdio.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#if HAVE_DIRENT_H
+#include <dirent.h>
+#define NAMLEN(dirent) strlen((dirent)->d_name)
+#else
+#define dirent direct
+#define NAMLEN(dirent) (dirent)->d_namlen
+#if HAVE_SYS_NDIR_H
+#include <sys/ndir.h>
+#endif
+#if HAVE_SYS_DIR_H
+#include <sys/dir.h>
+#endif
+#if HAVE_NDIR_H
+#include <ndir.h>
+#endif
+#endif
+
+#if HAVE_DIRECT_H
+#include <direct.h>
+#endif
+
+#if HAVE_I86_H
+#include <i86.h>
+#endif
+
+#if HAVE_SYS_WAIT_H
+# include <sys/wait.h>
+#endif
+#ifndef WEXITSTATUS
+# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
+#endif
+#ifndef WIFEXITED
+# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
+#endif
+
+#if GWINSZ_IN_SYS_IOCTL
+# include <sys/ioctl.h>
+#define SUN_STYLE_WINDOW_SIZING 1
+#else
+#if HAVE_TERMIOS_H
+# include <termios.h>
+#define SUN_STYLE_WINDOW_SIZING 1
+#endif
+#endif
+
+#if HAVE_TERMIO_H
+# include <termio.h>
+#endif
+
+#if HAVE_IO_H
+#include <io.h>
+#endif
+
+#if HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#if !defined(HAVE_TERMIO_H) && !defined(HAVE_TERMIOS_H)
+#if HAVE_SGTTY_H
+#include <sgtty.h>
+#endif
+#endif
+
+#if HAVE_SYS_FILE_H
+#include <sys/file.h>
+#endif
+
+#if HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
+#if HAVE_ERRNO_H
+#include <errno.h>
+#endif
+
+#if HAVE_SIGNAL_H
+#include <signal.h>
+#endif
+
+#if HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#if HAVE_TERMCAP_H
+#include <termcap.h>
+#endif
+
+/* current end of autoconf stuff*/
+
+#if HAVE_LIBTERMCAP
+#define TERMCAP
+#else
+#if defined(HAVE_LIBTERMINFO)
+#define TERMINFO
+#endif
+#endif
+
+#if !defined(TERMCAP) && !defined(TERMINFO)
+#if defined(HAVE_LIBNCURSES)
+#define TERMINFO
+#endif
+#endif
+
+
+/* we prefer select over poll */
+#if HAVE_SYS_SELECT_H
+#include <sys/select.h>
+#define HAS_SELECT
+#else
+#if HAVE_POLL_H
+#include <poll.h>
+#define HAS_POLL
+#endif
+#endif
+
+/*
+ * Digital Equpment VMS Operating System
+ */
+#ifdef VMS
+#include "tecvms.h"
+#endif
+
+#ifndef CAUSE_BUS_ERROR
+#define CAUSE_BUS_ERROR() \
+ { \
+ int fake_destination; \
+ fake_destination = *((int *)(0x0FFFFFFF)); \
+ (void)fake_destination; \
+ }
+#endif
+
+#ifdef MSDOS
+#include <conio.h>
+#endif
+
#define TECO_FILENAME_TOTAL_LENGTH FILENAME_MAX
#define TECO_FILENAME_COMPONENT_LENGTH 256
#define TECO_READONLY_NAME "visit"
#define TECO_INTERNAL_BUFFER_NAME "TECO-"
#define TERMCAP_BUFFER_SIZE 2048
-#define SCREEN_OUTPUT_BUFFER_SIZE 4096
#define SCREEN_RESERVED_LINES 2
#define SCREEN_MAX_LABEL_FIELDS 4
#define SCREEN_NOMINAL_LINE_WIDTH 132
@@ -67,8 +308,10 @@
#if defined(MSDOS) && !defined(__HUGE__)
/* make sure that all variables fit into 64kb */
#define PARSER_STRING_MAX 512
+#define SCREEN_OUTPUT_BUFFER_SIZE 512
#else
#define PARSER_STRING_MAX 1024
+#define SCREEN_OUTPUT_BUFFER_SIZE 4096
#endif
#define SEARCH_STRING_MAX PARSER_STRING_MAX
#define NORMAL_TAB_WIDTH 8
@@ -183,7 +426,7 @@ void do_return_checks(void);
*/
struct position_cache {
struct buff_line *lbp;
- int base;
+ unsigned long base;
};
#define BUFF_CACHE_CONTENTS(pos_cache) \
@@ -207,11 +450,11 @@ void do_return_checks(void);
char *name;
int buffer_number;
struct buff_header *next_header;
- char ismodified;
- char isreadonly;
- char isbackedup;
- int dot;
- int zee;
+ unsigned int ismodified : 1;
+ unsigned int isreadonly : 1;
+ unsigned int isbackedup : 1;
+ unsigned long dot;
+ unsigned long zee;
int ivalue;
struct position_cache pos_cache;
@@ -220,8 +463,8 @@ void do_return_checks(void);
struct buff_line {
int lin_magic;
- int buffer_size;
- int byte_count;
+ size_t buffer_size;
+ size_t byte_count;
char *buffer;
struct buff_line *next_line;
struct buff_line *prev_line;
@@ -232,7 +475,7 @@ void do_return_checks(void);
int fmt_magic;
struct buff_header *fmt_owning_buffer;
struct buff_line *fmt_buffer_line;
- int fmt_buffer_size;
+ size_t fmt_buffer_size;
short *fmt_buffer;
int fmt_sequence;
struct format_line *fmt_next_line;
@@ -241,8 +484,8 @@ void do_return_checks(void);
struct format_line *fmt_prev_alloc;
struct format_line *fmt_next_window;
struct format_line *fmt_prev_window;
- char fmt_in_use;
- char fmt_permanent;
+ unsigned int fmt_in_use : 1;
+ unsigned int fmt_permanent : 1;
struct screen_line *fmt_saved_line;
short fmt_visible_line_position;
struct window *fmt_window_ptr;
@@ -283,7 +526,7 @@ void do_return_checks(void);
};
struct search_buff {
- int length;
+ size_t length;
char input[PARSER_STRING_MAX];
struct search_element data[PARSER_STRING_MAX];
char error_message_given;
@@ -366,243 +609,6 @@ void do_return_checks(void);
typedef unsigned long teco_ptrint_t;
-/**
- * We define unix except for the really different operating systems, like
- * vms. It lets us write our own version of functions which simply do not
- * exist outside of unix.
- */
-#if !defined(VMS) && !defined(MSDOS)
-#define UNIX
-#define JOB_CONTROL
-#endif
-
-/*
- * Include Files From GNU Autoconf/Autoheader
- *
- * FIXME: The Autoconf build system does not pass down -DHAVE_CONFIG_H.
- * This should be fixed by rewriting it as the original sources
- * are missing.
- */
-//#ifdef HAVE_CONFIG_H
-#ifndef __WATCOMC__
-#include "config.h"
-#endif
-
-#ifdef HAVE_SYS_IOCTL_H
-#include <sys/ioctl.h>
-#endif
-
-/*
- * sys/filio.h has the FIONREAD definition
- */
-#ifdef HAVE_SYS_FILIO_H
-#include <sys/filio.h>
-#endif
-#ifdef FIONREAD
-#define HAS_FIONREAD
-#endif
-
-#if HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-#endif
-
-#if HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-#if STDC_HEADERS
-#include <stdlib.h>
-#include <stddef.h>
-#else
-#if HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#endif
-
-#if HAVE_STRING_H
-# if !STDC_HEADERS && HAVE_MEMORY_H
-# include <memory.h>
-# endif
-# include <string.h>
-# if !HAVE_STRCHR
-# if !defined(strchr)
-# define strchr index
-# endif
-# if !defined(strrchr)
-# define strrchr rindex
-# endif
-# endif
-#endif
-
-/* on SGI this gets us BZERO */
-#if HAVE_STRINGS_H
-#include <strings.h>
-#endif
-
-#if HAVE_INTTYPES_H
-#include <inttypes.h>
-#else
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-#endif
-
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-
-#if HAVE_DIRENT_H
-#include <dirent.h>
-#define NAMLEN(dirent) strlen((dirent)->d_name)
-#else
-#define dirent direct
-#define NAMLEN(dirent) (dirent)->d_namlen
-#if HAVE_SYS_NDIR_H
-#include <sys/ndir.h>
-#endif
-#if HAVE_SYS_DIR_H
-#include <sys/dir.h>
-#endif
-#if HAVE_NDIR_H
-#include <ndir.h>
-#endif
-#endif
-
-#if HAVE_DIRECT_H
-#include <direct.h>
-#endif
-
-#if HAVE_I86_H
-#include <i86.h>
-#endif
-
-#if HAVE_SYS_WAIT_H
-# include <sys/wait.h>
-#endif
-#ifndef WEXITSTATUS
-# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8)
-#endif
-#ifndef WIFEXITED
-# define WIFEXITED(stat_val) (((stat_val) & 255) == 0)
-#endif
-
-#if GWINSZ_IN_SYS_IOCTL
-# include <sys/ioctl.h>
-#define SUN_STYLE_WINDOW_SIZING 1
-#else
-#if HAVE_TERMIOS_H
-# include <termios.h>
-#define SUN_STYLE_WINDOW_SIZING 1
-#endif
-#endif
-
-#if HAVE_TERMIO_H
-# include <termio.h>
-#endif
-
-#if HAVE_IO_H
-#include <io.h>
-#endif
-
-#if HAVE_FCNTL_H
-#include <fcntl.h>
-#endif
-
-#if !defined(HAVE_TERMIO_H) && !defined(HAVE_TERMIOS_H)
-#if HAVE_SGTTY_H
-#include <sgtty.h>
-#endif
-#endif
-
-#if HAVE_SYS_FILE_H
-#include <sys/file.h>
-#endif
-
-#if HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
-#if HAVE_SYS_SOCKET_H
-#include <sys/socket.h>
-#endif
-
-#if HAVE_CTYPE_H
-#include <ctype.h>
-#endif
-
-#if HAVE_ERRNO_H
-#include <errno.h>
-#endif
-
-#if HAVE_SIGNAL_H
-#include <signal.h>
-#endif
-
-#if HAVE_PWD_H
-#include <pwd.h>
-#endif
-
-#if HAVE_TERMCAP_H
-#include <termcap.h>
-#endif
-
-/* current end of autoconf stuff*/
-
-#if HAVE_LIBTERMCAP
-#define TERMCAP
-#else
-#if defined(HAVE_LIBTERMINFO)
-#define TERMINFO
-#endif
-#endif
-
-#if !defined(TERMCAP) && !defined(TERMINFO)
-#if defined(HAVE_LIBNCURSES)
-#define TERMINFO
-#endif
-#endif
-
-
-/* we prefer select over poll */
-#if HAVE_SYS_SELECT_H
-#include <sys/select.h>
-#define HAS_SELECT
-#else
-#if HAVE_POLL_H
-#include <poll.h>
-#define HAS_POLL
-#endif
-#endif
-
-/*
- * Digital Equpment VMS Operating System
- */
-#ifdef VMS
-#include "tecvms.h"
-#endif
-
-#ifndef CAUSE_BUS_ERROR
-#define CAUSE_BUS_ERROR() \
- { \
- int fake_destination; \
- fake_destination = *((int *)(0x0FFFFFFF)); \
- (void)fake_destination; \
- }
-#endif
-
-#ifdef MSDOS
-#include <conio.h>
-#endif
-
/* method declarations */
void error_message(char * string);
void tec_release(unsigned char type, char *addr);
@@ -610,17 +616,17 @@ void tec_panic( char *string);
int buff_switch(struct buff_header *hbp,int map_flag);
int buff_read(struct buff_header *hbp,char *name);
int buff_readfd(struct buff_header *hbp,char *name,int iochan);
-int buff_insert(struct buff_header *hbp,int position,char *buffer,int length);
+int buff_insert(struct buff_header *hbp,unsigned long position,char *buffer,unsigned long length);
int screen_label_line(struct buff_header *buffer,char *string,int field);
-int buff_write(struct buff_header *hbp,int chan,int start,int end);
+int buff_write(struct buff_header *hbp,int chan,unsigned long start,unsigned long end);
void tecmem_stats(void);
void screen_free_format_lines(struct format_line *sbp);
-int buff_delete_char(struct buff_header *hbp,int position);
+int buff_delete_char(struct buff_header *hbp,unsigned long position);
int compile_search_string(struct search_buff *search_tbl);
-int cmd_forward_search(int pos1,int pos2,struct search_buff *search_tbl);
+int cmd_forward_search(unsigned long pos1,unsigned long pos2,struct search_buff *search_tbl);
int cmd_reverse_search(int pos1,int pos2,struct search_buff *search_tbl);
-int buff_cached_contents(struct buff_header *,int,struct position_cache *);
-int buff_contents(struct buff_header *hbp,int position);
+int buff_cached_contents(struct buff_header *,unsigned long,struct position_cache *);
+int buff_contents(struct buff_header *hbp,long position);
void pause_while_in_input_wait(void);
void restore_tty(void);
void initialize_tty(void);
@@ -631,7 +637,7 @@ void screen_message(char *string);
int tty_input_pending(void);
void screen_format_windows(void);
void load_qname_register(void);
-void buff_delete(struct buff_header *,int,int);
+void buff_delete(struct buff_header *,unsigned long,unsigned long);
void screen_reformat_windows(void);
int tag_calc_hash(char *string);
void tag_free_struct(struct tags *tp);
@@ -655,15 +661,15 @@ void screen_delete_window( struct window *old_wptr);
void buff_reopenbuff(struct buff_header *bp);
void buff_free_line_buffer_list(struct buff_line *);
int screen_display_window(struct window *wptr);
-int buff_find_offset(struct buff_header *,struct buff_line *,int);
+int buff_find_offset(struct buff_header *,struct buff_line *,long);
int buff_openbuffnum(int,int);
-int parse_illegal_buffer_position(int,int,char *);
-int buff_insert_char(struct buff_header *,int,char);
+int parse_illegal_buffer_position(long,long,char *);
+int buff_insert_char(struct buff_header *,unsigned long,char);
int push_qregister(char);
-void buff_bulk_insert(struct buff_header *,int,int,struct buff_line *);
+void buff_bulk_insert(struct buff_header *,unsigned long,long,struct buff_line *);
void buff_destroy(struct buff_header *);
-int cmd_wordmove(int count);
-int cmd_search(int,int,struct search_buff *);
+int cmd_wordmove(long count);
+int cmd_search(long,long,struct search_buff *);
int buff_openbuffer(char *,int,int);
int cmd_write(struct buff_header *,char *);
void screen_scroll(int);
@@ -691,11 +697,11 @@ void cmd_suspend(void);
int term_putnum(char *,int,int);
int term_scroll_region(int,int);
int init_term_description(void);
-char *tec_alloc(int,int);
+char *tec_alloc(int,size_t);
void initialize_memory_stats( void );
struct buff_header *buff_qfind(char,char);
char *error_text(int);
-struct buff_line *buff_find_line(struct buff_header *hbp,int);
+struct buff_line *buff_find_line(struct buff_header *hbp,unsigned long);
void term_insert_line(int,int);
void term_delete_line(int,int);
struct buff_header *buff_find(char *);