⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dflat.h

📁 edit 0.82 freedos中的文本编辑器
💻 H
📖 第 1 页 / 共 2 页
字号:
/* ------------- dflat.h ----------- */
#ifndef DFLAT_H
#define DFLAT_H

#ifdef BUILD_FULL_DFLAT
#define INCLUDE_MULTI_WINDOWS
/* #define INCLUDE_LOGGING */
#define INCLUDE_SHELLDOS
#define INCLUDE_WINDOWOPTIONS
#define INCLUDE_PICTUREBOX
#define INCLUDE_MINIMIZE
#define INCLUDE_MAXIMIZE
#define INCLUDE_RESTORE
#define INCLUDE_EXTENDEDSELECTIONS
#endif

/* To disable calendar item in utils define NOCALENDAR */
/* #define NOCALENDAR */

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <dos.h>
#include <process.h>
#include <conio.h>
#include <bios.h>
#include <ctype.h>
#include <io.h>
#include <sys\types.h>
#include <sys\stat.h>
#include <time.h>
#include <setjmp.h>

#ifndef VERSION
#define VERSION "0.82"
#endif

/* currently only required so config file created/opened in same dir as main executable */
#define ENABLEGLOBALARGV
#ifdef ENABLEGLOBALARGV
extern char **Argv;
#endif

void *DFcalloc(size_t, size_t);
void *DFmalloc(size_t);
void *DFrealloc(void *, size_t);

typedef enum {FALSE, TRUE} BOOL;

#define MAXMESSAGES 100
#define DELAYTICKS 1
#define FIRSTDELAY 7
#define DOUBLETICKS 5

#define MAXTEXTLEN 65000U /* maximum text buffer            */
#define EDITLEN     1024  /* starting length for multiliner */
#define ENTRYLEN     256  /* starting length for one-liner  */
#define GROWLENGTH    64  /* buffers grow by this much      */

#include "system.h"
#include "config.h"
#include "rect.h"
#include "menu.h"
#include "keys.h"
#include "commands.h"
#include "dialbox.h"
#include "helpbox.h"

/* ------ integer type for message parameters ----- */
typedef long PARAM;

enum Condition     {
    ISRESTORED, ISMINIMIZED, ISMAXIMIZED, ISCLOSING
};

typedef struct window {
    CLASS Class;           /* window class                  */
    char *title;           /* window title                  */
    int (*wndproc)
        (struct window *, enum messages, PARAM, PARAM);
    /* ---------------- window dimensions ----------------- */
    RECT rc;               /* window coordinates
                                            (0/0 to 79/24)  */
    int ht, wd;            /* window height and width       */
    RECT RestoredRC;       /* restored condition rect       */
    /* ----------------- window colors -------------------- */
    char WindowColors[4][2];
    /* -------------- linked list pointers ---------------- */
    struct window *parent; /* parent window                 */
    struct window *firstchild;  /* first child this parent  */
    struct window *lastchild;   /* last child this parent   */
    struct window *nextsibling; /* next sibling             */
    struct window *prevsibling; /* previous sibling         */

    struct window *childfocus;  /* child that ha(s/d) focus */
    int attrib;                 /* Window attributes        */
    char *videosave;            /* video save buffer        */
    enum Condition condition;   /* Restored, Maximized,
                                   Minimized, Closing       */
    enum Condition oldcondition;/* previous condition       */
    BOOL wasCleared;
    int restored_attrib;        /* attributes when restored */
    void *extension;      /* menus, dialogs, documents, etc */
    void *wrapper;             /* used by C++ wrapper class */
    struct window *PrevMouse;   /* previous mouse capture   */
    struct window *PrevKeyboard;/* previous keyboard capture*/
    struct window *PrevClock;   /* previous clock capture   */
    struct window *MenuBarWnd;/* menu bar                   */
    struct window *StatusBar; /* status bar                 */
    int isHelping;      /* > 0 when help is being displayed */
    /* ----------------- text box fields ------------------ */
    int wlines;     /* number of lines of text              */
    int wtop;       /* text line that is on the top display */
    unsigned char *text; /* window text                     */
    unsigned int textlen;  /* text length                   */
    int wleft;      /* left position in window viewport     */
    int textwidth;  /* width of longest line in textbox     */
    int BlkBegLine; /* beginning line of marked block       */
    int BlkBegCol;  /* beginning column of marked block     */
    int BlkEndLine; /* ending line of marked block          */
    int BlkEndCol;  /* ending column of marked block        */
    int HScrollBox; /* position of horizontal scroll box    */
    int VScrollBox; /* position of vertical scroll box      */
    unsigned int *TextPointers; /* -> list of line offsets  */
    /* ----------------- list box fields ------------------ */
    int selection;  /* current selection                    */
    BOOL AddMode;   /* adding extended selections mode      */
    int AnchorPoint;/* anchor point for extended selections */
    int SelectCount;/* count of selected items              */
    /* ----------------- edit box fields ------------------ */
    int CurrCol;      /* Current column                     */
    int CurrLine;     /* Current line                       */
    int WndRow;       /* Current window row                 */
    BOOL TextChanged; /* TRUE if text has changed           */
    BOOL protect;     /* TRUE to display '*'                */
    unsigned char *DeletedText; /* for undo                 */
    unsigned DeletedLength; /* Length of deleted field      */
    BOOL InsertMode;   /* TRUE or FALSE for text insert     */
    BOOL WordWrapMode; /* TRUE or FALSE for word wrap       */
    unsigned int MaxTextLength; /* maximum text length      */
    /* ---------------- dialog box fields ----------------- */
    int ReturnCode;        /* return code from a dialog box */
    BOOL Modal;            /* True if a modeless dialog box */
    CTLWINDOW *ct;         /* control structure             */
    struct window *dfocus; /* control window that has focus */
    /* -------------- popdownmenu fields ------------------ */
    MENU *mnu;      /* points to menu structure             */
    MBAR *holdmenu; /* previous active menu                 */
    struct window *oldFocus;
    /* -------------- status bar fields ------------------- */
    BOOL TimePosted; /* True if time has been posted        */
#ifdef INCLUDE_PICTUREBOX
    /* ------------- picture box fields ------------------- */
    int VectorCount;  /* number of vectors in vector list   */
    void *VectorList; /* list of picture box vectors        */
#endif
} * WINDOW;

#include "classdef.h"
#include "video.h"

void LogMessages (WINDOW, MESSAGE, PARAM, PARAM);
void MessageLog(WINDOW);
/* ------- window methods ----------- */
#define ICONHEIGHT 3
#define ICONWIDTH  10
#define WindowHeight(w)      ((w)->ht)
#define WindowWidth(w)       ((w)->wd)
#define BorderAdj(w)         (TestAttribute(w,HASBORDER)?1:0)
#define BottomBorderAdj(w)   (TestAttribute(w,HASSTATUSBAR)?1:BorderAdj(w))
#define TopBorderAdj(w)      ((TestAttribute(w,HASTITLEBAR) &&   \
                              TestAttribute(w,HASMENUBAR)) ?  \
                              2 : (TestAttribute(w,HASTITLEBAR | \
                              HASMENUBAR | HASBORDER) ? 1 : 0))
#define ClientWidth(w)       (WindowWidth(w)-BorderAdj(w)*2)
#define ClientHeight(w)      (WindowHeight(w)-TopBorderAdj(w)-\
                              BottomBorderAdj(w))
#define WindowRect(w)        ((w)->rc)
#define GetTop(w)            (RectTop(WindowRect(w)))
#define GetBottom(w)         (RectBottom(WindowRect(w)))
#define GetLeft(w)           (RectLeft(WindowRect(w)))
#define GetRight(w)          (RectRight(WindowRect(w)))
#define GetClientTop(w)      (GetTop(w)+TopBorderAdj(w))
#define GetClientBottom(w)   (GetBottom(w)-BottomBorderAdj(w))
#define GetClientLeft(w)     (GetLeft(w)+BorderAdj(w))
#define GetClientRight(w)    (GetRight(w)-BorderAdj(w))
#define GetTitle(w)          ((w)->title)
#define GetParent(w)         ((w)->parent)
#define FirstWindow(w)       ((w)->firstchild)
#define LastWindow(w)        ((w)->lastchild)
#define NextWindow(w)        ((w)->nextsibling)
#define PrevWindow(w)        ((w)->prevsibling)
#define GetClass(w)          ((w)->Class)
#define GetAttribute(w)      ((w)->attrib)
#define AddAttribute(w,a)    (GetAttribute(w) |= a)
#define ClearAttribute(w,a)  (GetAttribute(w) &= ~(a))
#define TestAttribute(w,a)   (GetAttribute(w) & (a))
#define isHidden(w)          (!(GetAttribute(w) & VISIBLE))
#define SetVisible(w)        (GetAttribute(w) |= VISIBLE)
#define ClearVisible(w)      (GetAttribute(w) &= ~VISIBLE)
#define gotoxy(w,x,y) cursor(w->rc.lf+(x)+1,w->rc.tp+(y)+1)
BOOL isVisible(WINDOW);
WINDOW CreateWindow(CLASS,const char *,int,int,int,int,void*,WINDOW,
       int (*)(struct window *,enum messages,PARAM,PARAM),int);
void AddTitle(WINDOW, const char *);
void InsertTitle(WINDOW, const char *);
void DisplayTitle(WINDOW, RECT *);
void RepaintBorder(WINDOW, RECT *);
void PaintShadow(WINDOW);
void ClearWindow(WINDOW, RECT *, int);
void writeline(WINDOW, char *, int, int, BOOL);
void InitWindowColors(WINDOW);

void SetNextFocus(void);
void SetPrevFocus(void);
void RemoveWindow(WINDOW);
void AppendWindow(WINDOW);
void ReFocus(WINDOW);
void SkipApplicationControls(void);

BOOL CharInView(WINDOW, int, int);
void CreatePath(char *, char *, int, int);
#define SwapVideoBuffer(wnd, ish, fh) swapvideo(wnd, wnd->videosave, ish, fh)
int LineLength(char *);
RECT AdjustRectangle(WINDOW, RECT);
BOOL isDerivedFrom(WINDOW, CLASS);
WINDOW GetAncestor(WINDOW);
void PutWindowChar(WINDOW,int,int,int);
void PutWindowLine(WINDOW, void *,int,int);
#define BaseWndProc(Class,wnd,msg,p1,p2)    \
    (*classdefs[(classdefs[Class].base)].wndproc)(wnd,msg,p1,p2)
#define DefaultWndProc(wnd,msg,p1,p2)         \
    (classdefs[wnd->Class].wndproc == NULL) ? \
    BaseWndProc(wnd->Class,wnd,msg,p1,p2) :   \
    (*classdefs[wnd->Class].wndproc)(wnd,msg,p1,p2)
struct LinkedList    {
    WINDOW FirstWindow;
    WINDOW LastWindow;
};
extern WINDOW ApplicationWindow;
extern WINDOW inFocus;
extern WINDOW CaptureMouse;
extern WINDOW CaptureKeyboard;
extern int foreground, background;
extern BOOL WindowMoving;
extern BOOL WindowSizing;
extern BOOL VSliding;
extern BOOL HSliding;
extern char DFlatApplication[];
extern char *Clipboard;
extern unsigned ClipboardLength;
extern BOOL ClipString;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -