[BACK]Return to gui.h CVS log [TXT][DIR] Up to [local] / src / usr.bin / vim

Annotation of src/usr.bin/vim/gui.h, Revision 1.1

1.1     ! downsj      1: /* $OpenBSD$   */
        !             2: /* vi:set ts=4 sw=4:
        !             3:  *
        !             4:  * VIM - Vi IMproved           by Bram Moolenaar
        !             5:  *                             Motif support by Robert Webb
        !             6:  *
        !             7:  * Do ":help uganda"  in Vim to read copying and usage conditions.
        !             8:  * Do ":help credits" in Vim to see a list of people who contributed.
        !             9:  */
        !            10:
        !            11: /* For debugging */
        !            12: /* #define D(x)    printf x; */
        !            13: #define D(x)
        !            14:
        !            15: #ifdef USE_GUI_MOTIF
        !            16: # define USE_GUI_X11
        !            17: # include <Xm/Xm.h>
        !            18: #endif
        !            19:
        !            20: /*
        !            21:  * No, Athena doesn't work.  Probably never will, there is probably a public
        !            22:  * domain X widget set that is more like Motif which should be used instead.
        !            23:  */
        !            24: #ifdef USE_GUI_ATHENA
        !            25: # define USE_GUI_X11
        !            26: # include <X11/Intrinsic.h>
        !            27: # include <X11/StringDefs.h>
        !            28: #endif
        !            29:
        !            30: /*
        !            31:  * These macros convert between character row/column and pixel coordinates.
        !            32:  * TEXT_X  - Convert character column into X pixel coord for drawing strings.
        !            33:  * TEXT_Y  - Convert character row into Y pixel coord for drawing strings.
        !            34:  * FILL_X  - Convert character column into X pixel coord for filling the area
        !            35:  *             under the character.
        !            36:  * FILL_Y  - Convert character row into Y pixel coord for filling the area
        !            37:  *             under the character.
        !            38:  * X_2_COL - Convert X pixel coord into character column.
        !            39:  * Y_2_ROW - Convert Y pixel coord into character row.
        !            40:  */
        !            41: #define TEXT_X(col)        ((col) * gui.char_width  + gui.border_offset)
        !            42: #define TEXT_Y(row)        ((row) * gui.char_height + gui.char_ascent \
        !            43:                                                 + gui.border_offset)
        !            44: #define FILL_X(col)        ((col) * gui.char_width  + gui.border_offset)
        !            45: #define FILL_Y(row)        ((row) * gui.char_height + gui.border_offset)
        !            46: #define X_2_COL(x)     (((x) - gui.border_offset) / gui.char_width)
        !            47: #define Y_2_ROW(y)     (((y) - gui.border_offset) / gui.char_height)
        !            48:
        !            49: /* Menu modes */
        !            50: #define MENU_NORMAL_MODE   0x01
        !            51: #define MENU_VISUAL_MODE   0x02
        !            52: #define MENU_INSERT_MODE   0x04
        !            53: #define MENU_CMDLINE_MODE  0x08
        !            54: #define MENU_ALL_MODES     0x0f
        !            55:
        !            56: /* Indices into GuiMenu->strings[] and GuiMenu->noremap[] for each mode */
        !            57: #define MENU_INDEX_INVALID -1
        !            58: #define MENU_INDEX_NORMAL  0
        !            59: #define MENU_INDEX_VISUAL  1
        !            60: #define MENU_INDEX_INSERT  2
        !            61: #define MENU_INDEX_CMDLINE 3
        !            62:
        !            63: /* Update types for scrollbars, getting more severe on the way down */
        !            64: #define SB_UPDATE_NOTHING  0
        !            65: #define SB_UPDATE_VALUE        1
        !            66: #define SB_UPDATE_HEIGHT   2
        !            67: #define SB_UPDATE_CREATE   3
        !            68:
        !            69: /* Indices for arrays of scrollbars */
        !            70: #define SB_NONE                -1
        !            71: #define SB_LEFT                0
        !            72: #define SB_RIGHT           1
        !            73: #define SB_BOTTOM          2
        !            74:
        !            75: /* Default size of scrollbar */
        !            76: #define SB_DEFAULT_WIDTH   20
        !            77:
        !            78: /* Default height of the menu bar */
        !            79: #define MENU_DEFAULT_HEIGHT 32
        !            80:
        !            81: /* Highlighting attribute bits. */
        !            82: #define HL_NORMAL              0x00
        !            83: #define HL_INVERSE             0x01
        !            84: #define HL_BOLD                    0x02
        !            85: #define HL_ITAL                    0x04
        !            86: #define HL_UNDERLINE           0x08
        !            87: #define HL_STANDOUT                0x10
        !            88: #define HL_SELECTED                0x20
        !            89: #define HL_ALL                 0x3f
        !            90:
        !            91: #ifdef USE_GUI_X11
        !            92:
        !            93: /* Selection states for X11 selection. */
        !            94: #define SELECT_CLEARED         0
        !            95: #define SELECT_IN_PROGRESS     1
        !            96: #define SELECT_DONE                2
        !            97:
        !            98: #define SELECT_MODE_CHAR       0
        !            99: #define SELECT_MODE_WORD       1
        !           100: #define SELECT_MODE_LINE       2
        !           101:
        !           102: #endif
        !           103:
        !           104: /*
        !           105:  * When we know the cursor is no longer being displayed (eg it has been written
        !           106:  * over).
        !           107:  */
        !           108: #define INVALIDATE_CURSOR()        (gui.cursor_row = -1)
        !           109:
        !           110: /* #define INVALIDATE_CURSOR() do{printf("Invalidate cursor %d\n", __LINE__); gui.cursor_row = -1;}while(0) */
        !           111:
        !           112: /*
        !           113:  * For checking whether cursor needs redrawing, or whether it doesn't need
        !           114:  * undrawing.
        !           115:  */
        !           116: #define IS_CURSOR_VALID()      (gui.cursor_row >= 0)
        !           117:
        !           118: typedef struct GuiSelection
        !           119: {
        !           120:    int         owned;              /* Flag: do we own the selection? */
        !           121:    FPOS        start;              /* Start of selected area */
        !           122:    FPOS        end;                /* End of selected area */
        !           123: #ifdef USE_GUI_X11
        !           124:    Atom        atom;               /* Vim's own special selection format */
        !           125:    short_u     origin_row;
        !           126:    short_u     origin_start_col;
        !           127:    short_u     origin_end_col;
        !           128:    short_u     word_start_col;
        !           129:    short_u     word_end_col;
        !           130:    FPOS        prev;               /* Previous position */
        !           131:    short_u     state;              /* Current selection state */
        !           132:    short_u     mode;               /* Select by char, word, or line. */
        !           133: #endif
        !           134: } GuiSelection;
        !           135:
        !           136: typedef struct GuiMenu
        !           137: {
        !           138:    int         modes;              /* Which modes is this menu visible for? */
        !           139:    char_u      *name;              /* Name shown in menu */
        !           140:    void        (*cb)();            /* Call-back routine */
        !           141:    char_u      *strings[4];        /* Mapped string for each mode */
        !           142:    int         noremap[4];         /* A noremap flag for each mode */
        !           143:    struct GuiMenu *children;       /* Children of sub-menu */
        !           144:    struct GuiMenu *next;           /* Next item in menu */
        !           145: #ifdef USE_GUI_X11
        !           146:    Widget      id;                 /* Manage this to enable item */
        !           147:    Widget      submenu_id;         /* If this is submenu, add children here */
        !           148: #endif
        !           149: } GuiMenu;
        !           150:
        !           151: typedef struct GuiScrollbar
        !           152: {
        !           153:    int         update[2];          /* What kind of update is required? */
        !           154:                                    /* (For left & right scrollbars) */
        !           155:    int         value;              /* Represents top line number visible */
        !           156:    int         size;               /* Size of scrollbar thumb */
        !           157:    int         max;                /* Number of lines in buffer */
        !           158:    int         top;                /* Top of scroll bar (chars from row 0) */
        !           159:    int         height;             /* Height of scroll bar (num rows) */
        !           160:    int         status_height;      /* Height of status line */
        !           161: #ifdef USE_GUI_X11
        !           162:    Widget      id[2];              /* Id of real scroll bar (left & right) */
        !           163: #endif
        !           164: } GuiScrollbar;
        !           165:
        !           166: typedef struct Gui
        !           167: {
        !           168:    int         in_focus;           /* Vim has input focus */
        !           169:    int         in_use;             /* Is the GUI being used? */
        !           170:    int         starting;           /* GUI will start in a little while */
        !           171:    int         dying;              /* Is vim dying? Then output to terminal */
        !           172:    int         dofork;             /* Use fork() when GUI is starting */
        !           173:    int         dragged_sb;         /* Which scrollbar being dragged, if any? */
        !           174:    struct window   *dragged_wp;    /* Which WIN's sb being dragged, if any? */
        !           175:    int         col;                /* Current cursor column in GUI display */
        !           176:    int         row;                /* Current cursor row in GUI display */
        !           177:    int         cursor_col;         /* Physical cursor column in GUI display */
        !           178:    int         cursor_row;         /* Physical cursor row in GUI display */
        !           179:    int         num_cols;           /* Number of columns */
        !           180:    int         num_rows;           /* Number of rows */
        !           181:    int         scroll_region_top;  /* Top (first) line of scroll region */
        !           182:    int         scroll_region_bot;  /* Bottom (last) line of scroll region */
        !           183:    long_u      highlight_mask;     /* Highlight attribute mask */
        !           184:    GuiSelection selection;         /* Info about selected text */
        !           185:    GuiMenu     *root_menu;         /* Root of menu hierarchy */
        !           186:    int         num_scrollbars;     /* Number of scrollbars (= #windows + 1) */
        !           187:    int         scrollbar_width;    /* Width of scrollbars */
        !           188:    int         menu_height;        /* Height of the menu bar */
        !           189:    int         menu_is_active;     /* TRUE if menu is present */
        !           190:    GuiScrollbar cmdline_sb;        /* Scroll bar for command line */
        !           191:                                    /* (Other scrollbars in 'struct window') */
        !           192:    int         which_scrollbars[3];/* Which scrollbar boxes are active? */
        !           193:    int         new_sb[3];          /* Which scrollbar boxes are new? */
        !           194:    int         prev_wrap;          /* For updating the horizontal scrollbar */
        !           195:    int         char_width;         /* Width of char in pixels */
        !           196:    int         char_height;        /* Height of char in pixels */
        !           197:    int         char_ascent;        /* Ascent of char in pixels */
        !           198:    int         border_width;       /* Width of our border around text area */
        !           199:    int         border_offset;      /* Total pixel offset for all borders */
        !           200: #ifdef USE_GUI_X11
        !           201:    Display     *dpy;               /* X display */
        !           202:    Window      wid;                /* Window id of text area */
        !           203:    int         visibility;         /* Is window partially/fully obscured? */
        !           204:    GC          text_gc;
        !           205:    GC          back_gc;
        !           206:    GC          invert_gc;
        !           207:    XFontStruct *norm_font;
        !           208:    XFontStruct *bold_font;
        !           209:    XFontStruct *ital_font;
        !           210:    XFontStruct *boldital_font;
        !           211:    Pixel       back_pixel;         /* Pixel value of background */
        !           212:    Pixel       norm_pixel;         /* Pixel value of normal text */
        !           213:    Pixel       bold_pixel;         /* Pixel value of bold text */
        !           214:    Pixel       ital_pixel;         /* Pixel value of ital text */
        !           215:    Pixel       underline_pixel;    /* Pixel value of underlined text */
        !           216:    Pixel       cursor_pixel;       /* Pixel value of cursor */
        !           217:    Pixel       menu_fg_pixel;      /* Pixel value of menu foregound */
        !           218:    Pixel       menu_bg_pixel;      /* Pixel value of menu backgound */
        !           219:    Pixel       scroll_fg_pixel;    /* Pixel value of scrollbar foreground */
        !           220:    Pixel       scroll_bg_pixel;    /* Pixel value of scrollbar background */
        !           221:
        !           222:    /* X Resources */
        !           223:    char_u      *dflt_font;         /* Resource font, used if 'font' not set */
        !           224:    char_u      *dflt_bold_fn;      /* Resource bold font */
        !           225:    char_u      *dflt_ital_fn;      /* Resource italic font */
        !           226:    char_u      *dflt_boldital_fn;  /* Resource bold-italic font */
        !           227:    char_u      *geom;              /* Geometry, eg "80x24" */
        !           228:    Bool        rev_video;          /* Use reverse video? */
        !           229: #endif
        !           230: } Gui;
        !           231:
        !           232: extern Gui gui;                        /* this is in gui.c */
        !           233: extern int force_menu_update;      /* this is in gui.c */