1 /** @file
2   data types that are used by editor
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 _HEDITOR_TYPE_H_
16 #define _HEDITOR_TYPE_H_
17 
18 #include "UefiShellDebug1CommandsLib.h"
19 #include "EditTitleBar.h"
20 
21 #define EFI_EDITOR_LINE_LIST  SIGNATURE_32 ('e', 'e', 'l', 'l')
22 
23 #define ASCII_POSITION        ((0x10 * 3) + 12)
24 
25 
26 typedef struct {
27   UINTN Row;
28   UINTN Column;
29 } HEFI_EDITOR_POSITION;
30 
31 typedef
32 EFI_STATUS
33 (*HEFI_MENU_ITEM_FUNCTION) (
34   VOID
35   );
36 
37 typedef struct {
38   CHAR16                  Name[50];
39   CHAR16                  Key[3];
40   HEFI_MENU_ITEM_FUNCTION Function;
41 } HMENU_ITEMS;
42 
43 typedef struct _HEFI_EDITOR_LINE {
44   UINTN           Signature;
45   UINT8           Buffer[0x10];
46   UINTN           Size;                             // unit is Unicode
47   LIST_ENTRY  Link;
48 } HEFI_EDITOR_LINE;
49 
50 typedef struct _HEFI_EDITOR_MENU_ITEM {
51   CHAR16                  NameToken;
52   CHAR16                  FunctionKeyToken;
53   HEFI_MENU_ITEM_FUNCTION Function;
54 } HEFI_EDITOR_MENU_ITEM;
55 
56 typedef struct {
57   UINT32  Foreground : 4;
58   UINT32  Background : 4;
59 } HEFI_EDITOR_COLOR_ATTRIBUTES;
60 
61 typedef union {
62   HEFI_EDITOR_COLOR_ATTRIBUTES  Colors;
63   UINTN                         Data;
64 } HEFI_EDITOR_COLOR_UNION;
65 
66 typedef struct {
67   UINTN Columns;
68   UINTN Rows;
69 } HEFI_EDITOR_TEXT_MODE;
70 
71 
72 typedef struct {
73   CHAR16  *Name;
74 
75   UINTN   BlockSize;
76   UINTN   Size;
77   UINTN   Offset;
78 } HEFI_EDITOR_DISK_IMAGE;
79 
80 typedef struct {
81   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *IoFncs;
82 
83   UINTN                           Offset;
84   UINTN                           Size;
85 } HEFI_EDITOR_MEM_IMAGE;
86 
87 typedef struct {
88   CHAR16  *FileName;
89   UINTN   Size;                                     // file size
90   BOOLEAN ReadOnly;                                 // file is read-only or not
91 } HEFI_EDITOR_FILE_IMAGE;
92 
93 typedef struct {
94   LIST_ENTRY                      *ListHead;        // list head of lines
95   HEFI_EDITOR_LINE                *Lines;           // lines of current file
96   UINTN                           NumLines;         // number of lines
97   HEFI_EDITOR_LINE                *CurrentLine;     // current line cursor is at
98   HEFI_EDITOR_POSITION            DisplayPosition;  // cursor position in screen
99   HEFI_EDITOR_POSITION            MousePosition;    // mouse position in screen
100   HEFI_EDITOR_POSITION            BufferPosition;   // cursor position in buffer
101   UINTN                           LowVisibleRow;    // the lowest visible row of file position
102   BOOLEAN                         HighBits;         // cursor is at the high4 bits or low4 bits
103   BOOLEAN                         Modified;         // BUFFER is modified or not
104   EDIT_FILE_TYPE                  BufferType;
105 
106   HEFI_EDITOR_FILE_IMAGE          *FileImage;
107   HEFI_EDITOR_DISK_IMAGE          *DiskImage;
108   HEFI_EDITOR_MEM_IMAGE           *MemImage;
109 
110 } HEFI_EDITOR_BUFFER_IMAGE;
111 
112 typedef struct {
113   HEFI_EDITOR_BUFFER_IMAGE    *BufferImage;
114 
115   HEFI_EDITOR_COLOR_UNION     ColorAttributes;
116   HEFI_EDITOR_POSITION        ScreenSize;           // row number and column number
117   BOOLEAN                     MouseSupported;
118   EFI_SIMPLE_POINTER_PROTOCOL *MouseInterface;
119   INT32                       MouseAccumulatorX;
120   INT32                       MouseAccumulatorY;
121 
122   UINTN                       SelectStart;          // starting from 1
123   UINTN                       SelectEnd;            // starting from 1
124 } HEFI_EDITOR_GLOBAL_EDITOR;
125 
126 #endif
127