Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

171 lines
3.6 KiB

  1. /*++
  2. Copyright (c) 1999 Intel Corporation
  3. Module Name:
  4. libStatus.c
  5. Abstract:
  6. Definition for the Status Bar - the updatable display for the status of the editor
  7. --*/
  8. #ifndef _LIB_STATUS_BAR
  9. #define _LIB_STATUS_BAR
  10. #include "editor.h"
  11. STATIC EFI_STATUS MainStatusBarInit (VOID);
  12. STATIC EFI_STATUS MainStatusBarCleanup (VOID);
  13. STATIC EFI_STATUS MainStatusBarRefresh (VOID);
  14. STATIC EFI_STATUS MainStatusBarHide (VOID);
  15. STATIC EFI_STATUS MainStatusBarSetStatusString (CHAR16*);
  16. STATIC EFI_STATUS MainStatusBarSetPosition (UINTN,UINTN);
  17. STATIC EFI_STATUS MainStatusBarSetMode (BOOLEAN);
  18. BOOLEAN InsertFlag=TRUE;
  19. EFI_EDITOR_STATUS_BAR MainStatusBar = {
  20. NULL,
  21. INSERT_MODE_STR,
  22. {1,1},
  23. MainStatusBarInit,
  24. MainStatusBarCleanup,
  25. MainStatusBarRefresh,
  26. MainStatusBarHide,
  27. MainStatusBarSetStatusString,
  28. MainStatusBarSetPosition,
  29. MainStatusBarSetMode
  30. };
  31. EFI_EDITOR_STATUS_BAR MainStatusBarConst = {
  32. NULL,
  33. INSERT_MODE_STR,
  34. {1,1},
  35. MainStatusBarInit,
  36. MainStatusBarCleanup,
  37. MainStatusBarRefresh,
  38. MainStatusBarHide,
  39. MainStatusBarSetStatusString,
  40. MainStatusBarSetPosition,
  41. MainStatusBarSetMode
  42. };
  43. STATIC
  44. EFI_STATUS
  45. MainStatusBarInit (
  46. VOID
  47. )
  48. {
  49. CopyMem (&MainStatusBar, &MainStatusBarConst, sizeof(MainStatusBar));
  50. MainStatusBar.SetStatusString(L"");
  51. return EFI_SUCCESS;
  52. }
  53. STATIC
  54. EFI_STATUS
  55. MainStatusBarCleanup (
  56. VOID
  57. )
  58. {
  59. MainEditor.FileBuffer->ClearLine(STATUS_BAR_LOCATION);
  60. if ( MainStatusBar.StatusString != NULL ) {
  61. FreePool ((VOID*)MainStatusBar.StatusString);
  62. }
  63. return EFI_SUCCESS;
  64. }
  65. STATIC
  66. EFI_STATUS
  67. MainStatusBarRefresh (
  68. VOID
  69. )
  70. {
  71. EFI_EDITOR_COLOR_UNION Orig,New;
  72. Orig = MainEditor.ColorAttributes;
  73. New.Colors.Foreground = Orig.Colors.Background;
  74. New.Colors.Background = Orig.Colors.Foreground;
  75. Out->SetAttribute (Out,New.Data);
  76. MainEditor.FileBuffer->ClearLine(STATUS_BAR_LOCATION);
  77. PrintAt (0,STATUS_BAR_LOCATION,L" Row: %d Col: %d %s",
  78. MainStatusBar.Pos.Row,MainStatusBar.Pos.Column,MainStatusBar.StatusString);
  79. if ( InsertFlag ) {
  80. PrintAt (MAX_TEXT_COLUMNS-10,STATUS_BAR_LOCATION,L"|%s|",L"INS");
  81. } else {
  82. PrintAt (MAX_TEXT_COLUMNS-10,STATUS_BAR_LOCATION,L"|%s|",L"OVR");
  83. }
  84. Out->SetAttribute (Out,Orig.Data);
  85. MainEditor.FileBuffer->RestorePosition();
  86. return EFI_SUCCESS;
  87. }
  88. STATIC
  89. EFI_STATUS
  90. MainStatusBarHide (
  91. VOID
  92. )
  93. {
  94. MainEditor.FileBuffer->ClearLine(STATUS_BAR_LOCATION);
  95. return EFI_SUCCESS;
  96. }
  97. STATIC
  98. EFI_STATUS
  99. MainStatusBarSetStatusString (
  100. IN CHAR16* Str
  101. )
  102. {
  103. if ( MainStatusBar.StatusString != NULL ) {
  104. FreePool (MainStatusBar.StatusString);
  105. }
  106. MainStatusBar.StatusString = StrDuplicate (Str);
  107. MainStatusBarRefresh();
  108. return EFI_SUCCESS;
  109. }
  110. STATIC
  111. EFI_STATUS
  112. MainStatusBarSetPosition (
  113. IN UINTN Row,
  114. IN UINTN Column
  115. )
  116. {
  117. MainStatusBar.Pos.Row = Row;
  118. MainStatusBar.Pos.Column = Column;
  119. MainStatusBar.Refresh();
  120. return EFI_SUCCESS;
  121. }
  122. STATIC
  123. EFI_STATUS
  124. MainStatusBarSetMode (
  125. BOOLEAN IsInsertMode
  126. )
  127. {
  128. InsertFlag = IsInsertMode;
  129. /*
  130. if (IsInsertMode) {
  131. StrCpy(MainStatusBar.ModeString,INSERT_MODE_STR);
  132. } else {
  133. StrCpy(MainStatusBar.ModeString,OVERWR_MODE_STR);
  134. }
  135. */
  136. return EFI_SUCCESS;
  137. }
  138. #endif /* _LIB_STATUS_BAR */