1 /** @file
2   Declares editor types.
3 
4   Copyright (c) 2005 - 2011, Intel Corporation. All rights reserved. <BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef _EDITOR_TYPE_H_
16 #define _EDITOR_TYPE_H_
17 
18 #include "UefiShellDebug1CommandsLib.h"
19 #include "EditTitleBar.h"
20 #include "EditMenuBar.h"
21 
22 #define MIN_POOL_SIZE         125
23 #define MAX_STRING_LENGTH     127
24 
25 typedef struct {
26   UINTN Row;
27   UINTN Column;
28 } EFI_EDITOR_POSITION;
29 
30 typedef
31 EFI_STATUS
32 (*EFI_MENU_ITEM_FUNCTION) (
33   VOID
34   );
35 
36 typedef enum {
37   NewLineTypeDefault,
38   NewLineTypeLineFeed,
39   NewLineTypeCarriageReturn,
40   NewLineTypeCarriageReturnLineFeed,
41   NewLineTypeLineFeedCarriageReturn,
42   NewLineTypeUnknown
43 } EE_NEWLINE_TYPE;
44 
45 #define LINE_LIST_SIGNATURE  SIGNATURE_32 ('e', 'e', 'l', 'l')
46 typedef struct _EFI_EDITOR_LINE {
47   UINTN           Signature;
48   CHAR16          *Buffer;
49   UINTN           Size;                   // unit is Unicode
50   UINTN           TotalSize;              // unit is Unicode, exclude CHAR_NULL
51   EE_NEWLINE_TYPE Type;
52   LIST_ENTRY      Link;
53 } EFI_EDITOR_LINE;
54 
55 typedef struct {
56   UINT32  Foreground : 4;
57   UINT32  Background : 4;
58 } EFI_EDITOR_COLOR_ATTRIBUTES;
59 
60 typedef union {
61   EFI_EDITOR_COLOR_ATTRIBUTES Colors;
62   UINTN                       Data;
63 } EFI_EDITOR_COLOR_UNION;
64 
65 typedef struct {
66   UINTN Columns;
67   UINTN Rows;
68 } EFI_EDITOR_TEXT_MODE;
69 
70 typedef struct {
71   CHAR16                *FileName;        // file name current edited in editor
72   EDIT_FILE_TYPE        FileType;         // Unicode file or ASCII file
73   LIST_ENTRY            *ListHead;        // list head of lines
74   EFI_EDITOR_LINE       *Lines;           // lines of current file
75   UINTN                 NumLines;         // total line numbers
76   EFI_EDITOR_POSITION   DisplayPosition;  // cursor position in screen
77   EFI_EDITOR_POSITION   FilePosition;     // cursor position in file
78   EFI_EDITOR_POSITION   MousePosition;    // mouse position in screen
79   // file position of first byte displayed on screen
80   //
81   EFI_EDITOR_POSITION   LowVisibleRange;
82 
83   BOOLEAN               FileModified;     // file is modified or not
84   BOOLEAN               ModeInsert;       // input mode INS or OVR
85   BOOLEAN               ReadOnly;         // file is read-only or not
86   EFI_EDITOR_LINE       *CurrentLine;     // current line cursor is at
87 } EFI_EDITOR_FILE_BUFFER;
88 
89 typedef struct {
90   EFI_EDITOR_FILE_BUFFER      *FileBuffer;
91 
92   EFI_EDITOR_COLOR_UNION      ColorAttributes;
93   EFI_EDITOR_POSITION         ScreenSize; // row number and column number
94   EFI_EDITOR_LINE             *CutLine;   // clip board
95   BOOLEAN                     MouseSupported;
96   EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
97   INT32                       MouseAccumulatorX;
98   INT32                       MouseAccumulatorY;
99 
100 } EFI_EDITOR_GLOBAL_EDITOR;
101 
102 #endif
103