File PromptRequest.cpp changed (mode: 100644) (index a6be77d..aaf8c27) |
... |
... |
private: |
69 |
69 |
struct sigaction sa; // Saved signal handling information. |
struct sigaction sa; // Saved signal handling information. |
70 |
70 |
}; |
}; |
71 |
71 |
|
|
|
72 |
|
// Hides cursor when an object of this type leaves scope. |
|
73 |
|
class AutoHideCursor |
|
74 |
|
{ |
|
75 |
|
public: |
|
76 |
|
// Remembers argument. |
|
77 |
|
explicit AutoHideCursor(cursed::Screen &screen) : screen(screen) |
|
78 |
|
{ } |
|
79 |
|
|
|
80 |
|
// Hides cursor. |
|
81 |
|
~AutoHideCursor() try { |
|
82 |
|
screen.hideCursor(); |
|
83 |
|
} catch (...) { } |
|
84 |
|
|
|
85 |
|
AutoHideCursor(const AutoHideCursor &rhs) = delete; |
|
86 |
|
AutoHideCursor(AutoHideCursor &&rhs) = delete; |
|
87 |
|
AutoHideCursor & operator=(const AutoHideCursor &rhs) = delete; |
|
88 |
|
AutoHideCursor & operator=(AutoHideCursor &&rhs) = delete; |
|
89 |
|
|
|
90 |
|
private: |
|
91 |
|
cursed::Screen &screen; // Screen on which to operate. |
|
92 |
|
}; |
|
93 |
|
|
72 |
94 |
} |
} |
73 |
95 |
|
|
74 |
96 |
void |
void |
|
... |
... |
PromptResult::PromptResult(std::wstring input, bool accepted) |
90 |
112 |
PromptRequest::PromptRequest(cursed::Screen &screen, cursed::Prompt &promptArea) |
PromptRequest::PromptRequest(cursed::Screen &screen, cursed::Prompt &promptArea) |
91 |
113 |
: input(cursed::Keypad::Disabled), screen(screen), promptArea(promptArea) |
: input(cursed::Keypad::Disabled), screen(screen), promptArea(promptArea) |
92 |
114 |
{ |
{ |
93 |
|
screen.showCursor(&promptArea); |
|
94 |
|
|
|
95 |
115 |
promptHi.setBold(true); |
promptHi.setBold(true); |
96 |
116 |
} |
} |
97 |
117 |
|
|
98 |
|
PromptRequest::~PromptRequest() |
|
99 |
|
{ |
|
100 |
|
screen.hideCursor(); |
|
101 |
|
} |
|
102 |
|
|
|
103 |
118 |
void |
void |
104 |
119 |
PromptRequest::setOnInputChanged(inputChangedFunc newOnInputChanged) |
PromptRequest::setOnInputChanged(inputChangedFunc newOnInputChanged) |
105 |
120 |
{ |
{ |
|
... |
... |
PromptResult |
116 |
131 |
PromptRequest::prompt(const std::wstring &invitation, |
PromptRequest::prompt(const std::wstring &invitation, |
117 |
132 |
const std::wstring &initial) |
const std::wstring &initial) |
118 |
133 |
{ |
{ |
|
134 |
|
screen.showCursor(&promptArea); |
|
135 |
|
AutoHideCursor autoHideCursor(screen); |
|
136 |
|
|
119 |
137 |
initialValue = cursed::toNarrow(initial); |
initialValue = cursed::toNarrow(initial); |
120 |
138 |
lastValue = initialValue; |
lastValue = initialValue; |
121 |
139 |
|
|
File PromptRequest.hpp changed (mode: 100644) (index 5af0750..c15eb62) |
... |
... |
class PromptRequest |
71 |
71 |
> completerFunc; |
> completerFunc; |
72 |
72 |
|
|
73 |
73 |
public: |
public: |
74 |
|
// Remembers arguments and makes cursor visible. |
|
|
74 |
|
// Remembers arguments. |
75 |
75 |
PromptRequest(cursed::Screen &screen, cursed::Prompt &promptArea); |
PromptRequest(cursed::Screen &screen, cursed::Prompt &promptArea); |
76 |
|
// Cleans up and hides cursor. |
|
77 |
|
~PromptRequest(); |
|
78 |
76 |
|
|
79 |
77 |
PromptRequest(const PromptRequest &rhs) = delete; |
PromptRequest(const PromptRequest &rhs) = delete; |
80 |
78 |
PromptRequest(PromptRequest &&rhs) = delete; |
PromptRequest(PromptRequest &&rhs) = delete; |