summaryrefslogtreecommitdiff
path: root/ShellPkg/Library/UefiShellDebug1CommandsLib/Edit/TextEditorTypes.h
blob: 327ecd2257b05e0514f1b554e2a32086ee2cc73e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/** @file
  Declares editor types.

  Copyright (c) 2005 - 2018, Intel Corporation. All rights reserved. <BR>
  SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#ifndef _EDITOR_TYPE_H_
#define _EDITOR_TYPE_H_

#include "UefiShellDebug1CommandsLib.h"
#include "EditTitleBar.h"
#include "EditMenuBar.h"

#define MIN_POOL_SIZE         125
#define MAX_STRING_LENGTH     127

typedef struct {
  UINTN Row;
  UINTN Column;
} EFI_EDITOR_POSITION;

typedef
EFI_STATUS
(*EFI_MENU_ITEM_FUNCTION) (
  VOID
  );

typedef enum {
  NewLineTypeDefault,
  NewLineTypeLineFeed,
  NewLineTypeCarriageReturn,
  NewLineTypeCarriageReturnLineFeed,
  NewLineTypeLineFeedCarriageReturn,
  NewLineTypeUnknown
} EE_NEWLINE_TYPE;

#define LINE_LIST_SIGNATURE  SIGNATURE_32 ('e', 'e', 'l', 'l')
typedef struct _EFI_EDITOR_LINE {
  UINTN           Signature;
  CHAR16          *Buffer;
  UINTN           Size;                   // unit is Unicode
  UINTN           TotalSize;              // unit is Unicode, exclude CHAR_NULL
  EE_NEWLINE_TYPE Type;
  LIST_ENTRY      Link;
} EFI_EDITOR_LINE;

typedef struct {
  UINT32  Foreground : 4;
  UINT32  Background : 4;
} EFI_EDITOR_COLOR_ATTRIBUTES;

typedef union {
  EFI_EDITOR_COLOR_ATTRIBUTES Colors;
  UINTN                       Data;
} EFI_EDITOR_COLOR_UNION;

typedef struct {
  UINTN Columns;
  UINTN Rows;
} EFI_EDITOR_TEXT_MODE;

typedef struct {
  CHAR16                *FileName;        // file name current edited in editor
  EDIT_FILE_TYPE        FileType;         // Unicode file or ASCII file
  LIST_ENTRY            *ListHead;        // list head of lines
  EFI_EDITOR_LINE       *Lines;           // lines of current file
  UINTN                 NumLines;         // total line numbers
  EFI_EDITOR_POSITION   DisplayPosition;  // cursor position in screen
  EFI_EDITOR_POSITION   FilePosition;     // cursor position in file
  EFI_EDITOR_POSITION   MousePosition;    // mouse position in screen
  // file position of first byte displayed on screen
  //
  EFI_EDITOR_POSITION   LowVisibleRange;

  BOOLEAN               FileModified;     // file is modified or not
  BOOLEAN               ModeInsert;       // input mode INS or OVR
  BOOLEAN               ReadOnly;         // file is read-only or not
  EFI_EDITOR_LINE       *CurrentLine;     // current line cursor is at
} EFI_EDITOR_FILE_BUFFER;

typedef struct {
  EFI_EDITOR_FILE_BUFFER            *FileBuffer;

  EFI_EDITOR_COLOR_UNION            ColorAttributes;
  EFI_EDITOR_POSITION               ScreenSize; // row number and column number
  EFI_EDITOR_LINE                   *CutLine;   // clip board
  EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *TextInputEx;
  BOOLEAN                           MouseSupported;
  EFI_SIMPLE_POINTER_PROTOCOL       *MouseInterface;
  INT32                             MouseAccumulatorX;
  INT32                             MouseAccumulatorY;

} EFI_EDITOR_GLOBAL_EDITOR;

#endif