TianoCore EDK2 master
Loading...
Searching...
No Matches
FileBuffer.c File Reference

Go to the source code of this file.

Functions

EFI_STATUS FileBufferInit (VOID)
 
EFI_STATUS FileBufferBackup (VOID)
 
EFI_EDITOR_LINEInternalEditorMiscLineAdvance (IN CONST UINTN Count, IN CONST EFI_EDITOR_LINE *CurrentLine, IN CONST LIST_ENTRY *LineList)
 
EFI_EDITOR_LINEInternalEditorMiscLineRetreat (IN CONST UINTN Count, IN CONST EFI_EDITOR_LINE *CurrentLine, IN CONST LIST_ENTRY *LineList)
 
EFI_EDITOR_LINEMoveLine (IN CONST INTN Count)
 
EFI_STATUS FileBufferRestoreMousePosition (VOID)
 
EFI_STATUS FileBufferFreeLines (VOID)
 
EFI_STATUS FileBufferCleanup (VOID)
 
EFI_STATUS FileBufferPrintLine (IN CONST EFI_EDITOR_LINE *Line, IN CONST UINTN Row)
 
EFI_STATUS FileBufferRestorePosition (VOID)
 
EFI_STATUS FileBufferRefresh (VOID)
 
EFI_EDITOR_LINEFileBufferCreateLine (VOID)
 
EFI_STATUS FileBufferSetFileName (IN CONST CHAR16 *Str)
 
EFI_STATUS FileBufferFree (VOID)
 
EFI_STATUS FileBufferRead (IN CONST CHAR16 *FileName, IN CONST BOOLEAN Recover)
 
VOID GetNewLine (IN CONST EE_NEWLINE_TYPE Type, OUT CHAR8 *Buffer, OUT UINT8 *Size)
 
UINTN UnicodeToAscii (IN CONST CHAR16 *UStr, IN CONST UINTN Length, OUT CHAR8 *AStr)
 
EFI_STATUS FileBufferSave (IN CONST CHAR16 *FileName)
 
EFI_STATUS FileBufferScrollLeft (VOID)
 
VOID LineDeleteAt (IN OUT EFI_EDITOR_LINE *Line, IN UINTN Pos)
 
VOID LineCat (IN OUT EFI_EDITOR_LINE *Dest, IN EFI_EDITOR_LINE *Src)
 
EFI_STATUS FileBufferDoBackspace (VOID)
 
EFI_STATUS FileBufferDoReturn (VOID)
 
EFI_STATUS FileBufferDoDelete (VOID)
 
EFI_STATUS FileBufferScrollRight (VOID)
 
UINTN LineStrInsert (IN EFI_EDITOR_LINE *Line, IN CHAR16 Char, IN UINTN Pos, IN UINTN StrSize)
 
EFI_STATUS FileBufferAddChar (IN CHAR16 Char)
 
EFI_STATUS FileBufferDoCharInput (IN CONST CHAR16 Char)
 
EFI_STATUS FileBufferScrollDown (VOID)
 
EFI_STATUS FileBufferScrollUp (VOID)
 
EFI_STATUS FileBufferPageDown (VOID)
 
EFI_STATUS FileBufferPageUp (VOID)
 
EFI_STATUS FileBufferEnd (VOID)
 
EFI_STATUS FileBufferHandleInput (IN CONST EFI_INPUT_KEY *Key)
 
BOOLEAN AboveCurrentScreen (IN UINTN FileRow)
 
BOOLEAN UnderCurrentScreen (IN UINTN FileRow)
 
BOOLEAN LeftCurrentScreen (IN UINTN FileCol)
 
BOOLEAN RightCurrentScreen (IN UINTN FileCol)
 
EFI_EDITOR_LINEMoveCurrentLine (IN INTN Count)
 
VOID FileBufferMovePosition (IN CONST UINTN NewFilePosRow, IN CONST UINTN NewFilePosCol)
 
EFI_STATUS FileBufferCutLine (OUT EFI_EDITOR_LINE **CutLine)
 
EFI_STATUS FileBufferPasteLine (VOID)
 
EFI_STATUS FileBufferSearch (IN CONST CHAR16 *Str, IN CONST UINTN Offset)
 
EFI_STATUS FileBufferReplace (IN CONST CHAR16 *Replace, IN CONST UINTN SearchLen)
 
VOID FileBufferAdjustMousePosition (IN CONST INT32 TextX, IN CONST INT32 TextY)
 
EFI_STATUS FileBufferReplaceAll (IN CHAR16 *SearchStr, IN CHAR16 *ReplaceStr, IN UINTN Offset)
 
VOID FileBufferSetModified (VOID)
 

Variables

EFI_EDITOR_FILE_BUFFER FileBuffer
 
EFI_EDITOR_FILE_BUFFER FileBufferBackupVar
 
EFI_EDITOR_FILE_BUFFER FileBufferConst
 
BOOLEAN FileBufferNeedRefresh
 
BOOLEAN FileBufferOnlyLineNeedRefresh
 
BOOLEAN FileBufferMouseNeedRefresh
 
BOOLEAN EditorMouseAction
 

Detailed Description

Implements filebuffer interface functions.

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

Definition in file FileBuffer.c.

Function Documentation

◆ AboveCurrentScreen()

BOOLEAN AboveCurrentScreen ( IN UINTN  FileRow)

Check user specified FileRow is above current screen.

Parameters
[in]FileRowThe row of file position ( start from 1 ).
Return values
TRUEIt is above the current screen.
FALSEIt is not above the current screen.

Definition at line 2553 of file FileBuffer.c.

◆ FileBufferAddChar()

EFI_STATUS FileBufferAddChar ( IN CHAR16  Char)

Add a character to the current line.

Parameters
[in]CharThe Character to input.
Return values
EFI_SUCCESSThe input was succesful.

Definition at line 2113 of file FileBuffer.c.

◆ FileBufferAdjustMousePosition()

VOID FileBufferAdjustMousePosition ( IN CONST INT32  TextX,
IN CONST INT32  TextY 
)

Move the mouse cursor position.

Parameters
[in]TextXThe new x-coordinate.
[in]TextYThe new y-coordinate.

Definition at line 3158 of file FileBuffer.c.

◆ FileBufferBackup()

EFI_STATUS FileBufferBackup ( VOID  )

Backup function for FileBuffer. Only backup the following items: Mouse/Cursor position File Name, Type, ReadOnly, Modified Insert Mode

This is for making the file buffer refresh as few as possible.

Return values
EFI_SUCCESSThe backup operation was successful.

Definition at line 117 of file FileBuffer.c.

◆ FileBufferCleanup()

EFI_STATUS FileBufferCleanup ( VOID  )

Cleanup function for FileBuffer.

Return values
EFI_SUCCESSThe cleanup was successful.

Definition at line 445 of file FileBuffer.c.

◆ FileBufferCreateLine()

EFI_EDITOR_LINE * FileBufferCreateLine ( VOID  )

Create a new line and append it to the line list. Fields affected: NumLines Lines

Return values
NULLThe create line failed.
Returns
The line created.

Definition at line 664 of file FileBuffer.c.

◆ FileBufferCutLine()

EFI_STATUS FileBufferCutLine ( OUT EFI_EDITOR_LINE **  CutLine)

Cut current line out and return a pointer to it.

Parameters
[out]CutLineUpon a successful return pointer to the pointer to the allocated cut line.
Return values
EFI_SUCCESSThe cut was successful.
EFI_NOT_FOUNDThere was no selection to cut.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 2791 of file FileBuffer.c.

◆ FileBufferDoBackspace()

EFI_STATUS FileBufferDoBackspace ( VOID  )

Delete the previous character.

Return values
EFI_SUCCESSThe delete was successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 1776 of file FileBuffer.c.

◆ FileBufferDoCharInput()

EFI_STATUS FileBufferDoCharInput ( IN CONST CHAR16  Char)

Handles inputs from characters (ASCII key + Backspace + return)

Parameters
[in]CharThe input character.
Return values
EFI_SUCCESSThe operation was successful.
EFI_LOAD_ERRORThere was an error.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 2161 of file FileBuffer.c.

◆ FileBufferDoDelete()

EFI_STATUS FileBufferDoDelete ( VOID  )

Delete current character from current line. This is the effect caused by the 'del' key.

Return values
EFI_SUCCESS

Definition at line 1944 of file FileBuffer.c.

◆ FileBufferDoReturn()

EFI_STATUS FileBufferDoReturn ( VOID  )

Add a return into line at current position.

Return values
EFI_SUCCESSThe insetrion of the character was successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 1847 of file FileBuffer.c.

◆ FileBufferEnd()

EFI_STATUS FileBufferEnd ( VOID  )

Scroll cursor to end of the current line.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 2401 of file FileBuffer.c.

◆ FileBufferFree()

EFI_STATUS FileBufferFree ( VOID  )

Free the existing file lines and reset the modified flag.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 752 of file FileBuffer.c.

◆ FileBufferFreeLines()

EFI_STATUS FileBufferFreeLines ( VOID  )

Free all the lines in FileBuffer Fields affected: Lines CurrentLine NumLines ListHead

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 402 of file FileBuffer.c.

◆ FileBufferHandleInput()

EFI_STATUS FileBufferHandleInput ( IN CONST EFI_INPUT_KEY Key)

Dispatch input to different handler

Parameters
[in]KeyThe input key. One of: ASCII KEY Backspace/Delete Return Direction key: up/down/left/right/pgup/pgdn Home/End INS
Return values
EFI_SUCCESSThe dispatch was done successfully.
EFI_LOAD_ERRORThe dispatch was not successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 2438 of file FileBuffer.c.

◆ FileBufferInit()

EFI_STATUS FileBufferInit ( VOID  )

Initialization function for FileBuffer.

Parameters
EFI_SUCCESSThe initialization was successful.
EFI_LOAD_ERRORA default name could not be created.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 69 of file FileBuffer.c.

◆ FileBufferMovePosition()

VOID FileBufferMovePosition ( IN CONST UINTN  NewFilePosRow,
IN CONST UINTN  NewFilePosCol 
)

According to cursor's file position, adjust screen display

Parameters
[in]NewFilePosRowThe row of file position ( start from 1 ).
[in]NewFilePosColThe column of file position ( start from 1 ).

Definition at line 2677 of file FileBuffer.c.

◆ FileBufferPageDown()

EFI_STATUS FileBufferPageDown ( VOID  )

Scroll cursor to next page.

Return values
EFI_SUCCESSThe operation wa successful.

Definition at line 2295 of file FileBuffer.c.

◆ FileBufferPageUp()

EFI_STATUS FileBufferPageUp ( VOID  )

Scroll cursor to previous screen.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 2346 of file FileBuffer.c.

◆ FileBufferPasteLine()

EFI_STATUS FileBufferPasteLine ( VOID  )

Paste a line into line list.

Return values
EFI_SUCCESSThe paste was successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 2874 of file FileBuffer.c.

◆ FileBufferPrintLine()

EFI_STATUS FileBufferPrintLine ( IN CONST EFI_EDITOR_LINE Line,
IN CONST UINTN  Row 
)

Print a line specified by Line on a row specified by Row of the screen.

Parameters
[in]LineThe line to print.
[in]RowThe row on the screen to print onto (begin from 1).
Return values
EFI_SUCCESSThe printing was successful.

Definition at line 474 of file FileBuffer.c.

◆ FileBufferRead()

EFI_STATUS FileBufferRead ( IN CONST CHAR16 *  FileName,
IN CONST BOOLEAN  Recover 
)

Read a file from disk into the FileBuffer.

Parameters
[in]FileNameThe filename to read.
[in]RecoverTRUE if is for recover mode, no information printouts.
Return values
EFI_SUCCESSThe load was successful.
EFI_LOAD_ERRORThe load failed.
EFI_OUT_OF_RESOURCESA memory allocation failed.
EFI_INVALID_PARAMETERFileName is a directory.

Definition at line 777 of file FileBuffer.c.

◆ FileBufferRefresh()

EFI_STATUS FileBufferRefresh ( VOID  )

Refresh the screen with whats in the buffer.

Return values
EFI_SUCCESSThe refresh was successful.
EFI_LOAD_ERRORThere was an error finding what to write.

Definition at line 551 of file FileBuffer.c.

◆ FileBufferReplace()

EFI_STATUS FileBufferReplace ( IN CONST CHAR16 *  Replace,
IN CONST UINTN  SearchLen 
)

Replace SearchLen characters from current position on with Replace.

This will modify the current buffer at the current position.

Parameters
[in]ReplaceThe string to replace.
[in]SearchLenSearch string's length.
Return values
EFI_SUCCESSThe operation was successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.

Definition at line 3052 of file FileBuffer.c.

◆ FileBufferReplaceAll()

EFI_STATUS FileBufferReplaceAll ( IN CHAR16 *  SearchStr,
IN CHAR16 *  ReplaceStr,
IN UINTN  Offset 
)

Search and replace operation.

Parameters
[in]SearchStrThe string to search for.
[in]ReplaceStrThe string to replace with.
[in]OffsetThe column to start at.

Definition at line 3235 of file FileBuffer.c.

◆ FileBufferRestoreMousePosition()

EFI_STATUS FileBufferRestoreMousePosition ( VOID  )

Function to update the 'screen' to display the mouse position.

Return values
EFI_SUCCESSThe backup operation was successful.

Definition at line 255 of file FileBuffer.c.

◆ FileBufferRestorePosition()

EFI_STATUS FileBufferRestorePosition ( VOID  )

Set the cursor position according to FileBuffer.DisplayPosition.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 530 of file FileBuffer.c.

◆ FileBufferSave()

EFI_STATUS FileBufferSave ( IN CONST CHAR16 *  FileName)

Save lines in FileBuffer to disk

Parameters
[in]FileNameThe file name for writing.
Return values
EFI_SUCCESSData was written.
EFI_LOAD_ERROR
EFI_OUT_OF_RESOURCESThere were not enough resources to write the file.

Definition at line 1425 of file FileBuffer.c.

◆ FileBufferScrollDown()

EFI_STATUS FileBufferScrollDown ( VOID  )

Scroll cursor to the next line.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 2210 of file FileBuffer.c.

◆ FileBufferScrollLeft()

EFI_STATUS FileBufferScrollLeft ( VOID  )

Scroll cursor to left 1 character position.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 1666 of file FileBuffer.c.

◆ FileBufferScrollRight()

EFI_STATUS FileBufferScrollRight ( VOID  )

Scroll cursor to right 1 character.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 2006 of file FileBuffer.c.

◆ FileBufferScrollUp()

EFI_STATUS FileBufferScrollUp ( VOID  )

Scroll the cursor to previous line.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 2254 of file FileBuffer.c.

◆ FileBufferSearch()

EFI_STATUS FileBufferSearch ( IN CONST CHAR16 *  Str,
IN CONST UINTN  Offset 
)

Search string from current position on in file

Parameters
[in]StrThe search string.
[in]OffsetThe offset from current position.
Return values
EFI_SUCCESSThe operation was successful.
EFI_NOT_FOUNDThe string Str was not found.

Definition at line 2947 of file FileBuffer.c.

◆ FileBufferSetFileName()

EFI_STATUS FileBufferSetFileName ( IN CONST CHAR16 *  Str)

Set FileName field in FileBuffer.

Parameters
StrThe file name to set.
Return values
EFI_SUCCESSThe filename was successfully set.
EFI_OUT_OF_RESOURCESA memory allocation failed.
EFI_INVALID_PARAMETERStr is not a valid filename.

Definition at line 719 of file FileBuffer.c.

◆ FileBufferSetModified()

VOID FileBufferSetModified ( VOID  )

Set the modified state to TRUE.

Definition at line 3354 of file FileBuffer.c.

◆ GetNewLine()

VOID GetNewLine ( IN CONST EE_NEWLINE_TYPE  Type,
OUT CHAR8 *  Buffer,
OUT UINT8 *  Size 
)

According to FileBuffer.NewLineType & FileBuffer.FileType, get the return buffer and size.

Parameters
[in]TypeThe type of line.
[out]BufferThe buffer to fill.
[out]SizeThe amount of the buffer used on return.

Definition at line 1288 of file FileBuffer.c.

◆ InternalEditorMiscLineAdvance()

EFI_EDITOR_LINE * InternalEditorMiscLineAdvance ( IN CONST UINTN  Count,
IN CONST EFI_EDITOR_LINE CurrentLine,
IN CONST LIST_ENTRY LineList 
)

Advance to the next Count lines

Parameters
[in]CountThe line number to advance by.
[in]CurrentLineThe pointer to the current line structure.
[in]LineListThe pointer to the linked list of lines.
Return values
NULLThere was an error.
Returns
The line structure after the advance.

Definition at line 150 of file FileBuffer.c.

◆ InternalEditorMiscLineRetreat()

EFI_EDITOR_LINE * InternalEditorMiscLineRetreat ( IN CONST UINTN  Count,
IN CONST EFI_EDITOR_LINE CurrentLine,
IN CONST LIST_ENTRY LineList 
)

Retreat to the previous Count lines.

Parameters
[in]CountThe line number to retreat by.
[in]CurrentLineThe pointer to the current line structure.
[in]LineListThe pointer to the linked list of lines.
Return values
NULLThere was an error.
Returns
The line structure after the retreat.

Definition at line 189 of file FileBuffer.c.

◆ LeftCurrentScreen()

BOOLEAN LeftCurrentScreen ( IN UINTN  FileCol)

Check user specified FileCol is left to current screen.

Parameters
[in]FileColThe column of file position ( start from 1 ).
Return values
TRUEIt is to the left.
FALSEIt is not to the left.

Definition at line 2599 of file FileBuffer.c.

◆ LineCat()

VOID LineCat ( IN OUT EFI_EDITOR_LINE Dest,
IN EFI_EDITOR_LINE Src 
)

Concatenate Src into Dest.

Parameters
[in,out]DestDestination string
[in]SrcSrc String.

Definition at line 1736 of file FileBuffer.c.

◆ LineDeleteAt()

VOID LineDeleteAt ( IN OUT EFI_EDITOR_LINE Line,
IN UINTN  Pos 
)

Delete a char in line

Parameters
[in,out]LineThe line to delete in.
[in]PosPosition to delete the char at ( start from 0 ).

Definition at line 1712 of file FileBuffer.c.

◆ LineStrInsert()

UINTN LineStrInsert ( IN EFI_EDITOR_LINE Line,
IN CHAR16  Char,
IN UINTN  Pos,
IN UINTN  StrSize 
)

Insert a char into line

Parameters
[in]LineThe line to insert into.
[in]CharThe char to insert.
[in]PosThe position to insert the char at ( start from 0 ).
[in]StrSizeThe current string size ( include CHAR_NULL ),unit is Unicode character.
Returns
The new string size ( include CHAR_NULL ) ( unit is Unicode character ).

Definition at line 2059 of file FileBuffer.c.

◆ MoveCurrentLine()

EFI_EDITOR_LINE * MoveCurrentLine ( IN INTN  Count)

Advance/Retreat lines and set CurrentLine in FileBuffer to it

Parameters
[in]CountThe line number to advance/retreat >0 : advance <0: retreat
Return values
NULLAn error occurred.
Returns
The line after advance/retreat.

Definition at line 2647 of file FileBuffer.c.

◆ MoveLine()

EFI_EDITOR_LINE * MoveLine ( IN CONST INTN  Count)

Advance/Retreat lines

Parameters
[in]Countline number to advance/retreat >0 : advance <0 : retreat
Return values
NULLAn error occurred.
Returns
The line after advance/retreat.

Definition at line 228 of file FileBuffer.c.

◆ RightCurrentScreen()

BOOLEAN RightCurrentScreen ( IN UINTN  FileCol)

Check user specified FileCol is right to current screen.

Parameters
[in]FileColThe column of file position ( start from 1 ).
Return values
TRUEIt is to the right.
FALSEIt is not to the right.

Definition at line 2622 of file FileBuffer.c.

◆ UnderCurrentScreen()

BOOLEAN UnderCurrentScreen ( IN UINTN  FileRow)

Check user specified FileRow is under current screen.

Parameters
[in]FileRowThe row of file position ( start from 1 ).
Return values
TRUEIt is under the current screen.
FALSEIt is not under the current screen.

Definition at line 2576 of file FileBuffer.c.

◆ UnicodeToAscii()

UINTN UnicodeToAscii ( IN CONST CHAR16 *  UStr,
IN CONST UINTN  Length,
OUT CHAR8 *  AStr 
)

Change a Unicode string to an ASCII string.

Parameters
[in]UStrThe Unicode string.
[in]LengthThe maximum size of AStr.
[out]AStrASCII string to pass out.
Returns
The actuall length.

Definition at line 1397 of file FileBuffer.c.

Variable Documentation

◆ EditorMouseAction

BOOLEAN EditorMouseAction
extern

Definition at line 24 of file MainTextEditor.c.

◆ FileBuffer

Definition at line 13 of file FileBuffer.c.

◆ FileBufferBackupVar

EFI_EDITOR_FILE_BUFFER FileBufferBackupVar

Definition at line 14 of file FileBuffer.c.

◆ FileBufferConst

EFI_EDITOR_FILE_BUFFER FileBufferConst
Initial value:
= {
FileTypeUnicode,
0,
{
0,
0
},
{
0,
0
},
{
0,
0
},
{
0,
0
},
}
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307

Definition at line 19 of file FileBuffer.c.

◆ FileBufferMouseNeedRefresh

BOOLEAN FileBufferMouseNeedRefresh

Definition at line 57 of file FileBuffer.c.

◆ FileBufferNeedRefresh

BOOLEAN FileBufferNeedRefresh

Definition at line 50 of file FileBuffer.c.

◆ FileBufferOnlyLineNeedRefresh

BOOLEAN FileBufferOnlyLineNeedRefresh

Definition at line 55 of file FileBuffer.c.