ccmake: Show the cursor only when in text editing mode
Additionally, stretch the current row highlight to cover the whole left column. Fixes: #4025
This commit is contained in:
parent
2308e23c7f
commit
fa96d1b42d
@ -29,7 +29,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||||||
{
|
{
|
||||||
this->Label =
|
this->Label =
|
||||||
cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
|
cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
|
||||||
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, " ");
|
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(3, 1, 1, 1, " ");
|
||||||
this->Entry =
|
this->Entry =
|
||||||
cm::make_unique<cmCursesStringWidget>(this->EntryWidth, 1, 1, 1);
|
cm::make_unique<cmCursesStringWidget>(this->EntryWidth, 1, 1, 1);
|
||||||
}
|
}
|
||||||
@ -44,9 +44,9 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite(
|
|||||||
this->Label =
|
this->Label =
|
||||||
cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
|
cm::make_unique<cmCursesLabelWidget>(this->LabelWidth, 1, 1, 1, key);
|
||||||
if (isNew) {
|
if (isNew) {
|
||||||
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, "*");
|
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(3, 1, 1, 1, " * ");
|
||||||
} else {
|
} else {
|
||||||
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(1, 1, 1, 1, " ");
|
this->IsNewLabel = cm::make_unique<cmCursesLabelWidget>(3, 1, 1, 1, " ");
|
||||||
}
|
}
|
||||||
|
|
||||||
cmValue value = state->GetCacheEntryValue(key);
|
cmValue value = state->GetCacheEntryValue(key);
|
||||||
|
@ -72,6 +72,9 @@ bool cmCursesMainForm::LookForCacheEntry(std::string const& key)
|
|||||||
// Create new cmCursesCacheEntryComposite entries from the cache
|
// Create new cmCursesCacheEntryComposite entries from the cache
|
||||||
void cmCursesMainForm::InitializeUI()
|
void cmCursesMainForm::InitializeUI()
|
||||||
{
|
{
|
||||||
|
// Hide the cursor by default
|
||||||
|
curs_set(0);
|
||||||
|
|
||||||
// Create a vector of cmCursesCacheEntryComposite's
|
// Create a vector of cmCursesCacheEntryComposite's
|
||||||
// which contain labels, entries and new entry markers
|
// which contain labels, entries and new entry markers
|
||||||
std::vector<cmCursesCacheEntryComposite> newEntries;
|
std::vector<cmCursesCacheEntryComposite> newEntries;
|
||||||
@ -271,7 +274,7 @@ void cmCursesMainForm::Render(int left, int top, int width, int height)
|
|||||||
this->NumberOfPages++;
|
this->NumberOfPages++;
|
||||||
}
|
}
|
||||||
entry.Label->Move(left, top + row - 1, isNewPage);
|
entry.Label->Move(left, top + row - 1, isNewPage);
|
||||||
entry.IsNewLabel->Move(left + 32, top + row - 1, false);
|
entry.IsNewLabel->Move(left + 30, top + row - 1, false);
|
||||||
entry.Entry->Move(left + 33, top + row - 1, false);
|
entry.Entry->Move(left + 33, top + row - 1, false);
|
||||||
entry.Entry->SetPage(this->NumberOfPages);
|
entry.Entry->SetPage(this->NumberOfPages);
|
||||||
i++;
|
i++;
|
||||||
@ -424,8 +427,11 @@ void cmCursesMainForm::UpdateStatusBar(cm::optional<std::string> message)
|
|||||||
// Fields are grouped by 3, the first one being the label
|
// Fields are grouped by 3, the first one being the label
|
||||||
// so start at 0 and move up by 3 avoiding the last null entry
|
// so start at 0 and move up by 3 avoiding the last null entry
|
||||||
for (size_type index = 0; index < this->Fields.size() - 1; index += 3) {
|
for (size_type index = 0; index < this->Fields.size() - 1; index += 3) {
|
||||||
bool currentLabel = index == currentLabelIndex;
|
int attr = (index == currentLabelIndex) ? A_STANDOUT : A_NORMAL;
|
||||||
set_field_fore(this->Fields[index], currentLabel ? A_STANDOUT : A_NORMAL);
|
set_field_fore(this->Fields[index], attr);
|
||||||
|
set_field_back(this->Fields[index], attr);
|
||||||
|
set_field_fore(this->Fields[index + 1], attr);
|
||||||
|
set_field_back(this->Fields[index + 1], attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display CMake version under the status bar
|
// Display CMake version under the status bar
|
||||||
@ -658,6 +664,12 @@ void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmCursesMainForm::SetSearchMode(bool enable)
|
||||||
|
{
|
||||||
|
this->SearchMode = enable;
|
||||||
|
curs_set(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void cmCursesMainForm::HandleInput()
|
void cmCursesMainForm::HandleInput()
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
@ -710,7 +722,7 @@ void cmCursesMainForm::HandleInput()
|
|||||||
|
|
||||||
if (this->SearchMode) {
|
if (this->SearchMode) {
|
||||||
if (key == 10 || key == KEY_ENTER) {
|
if (key == 10 || key == KEY_ENTER) {
|
||||||
this->SearchMode = false;
|
this->SetSearchMode(false);
|
||||||
if (!this->SearchString.empty()) {
|
if (!this->SearchString.empty()) {
|
||||||
this->JumpToCacheEntry(this->SearchString.c_str());
|
this->JumpToCacheEntry(this->SearchString.c_str());
|
||||||
this->OldSearchString = this->SearchString;
|
this->OldSearchString = this->SearchString;
|
||||||
@ -865,7 +877,7 @@ void cmCursesMainForm::HandleInput()
|
|||||||
CurrentForm = this;
|
CurrentForm = this;
|
||||||
this->Render(1, 1, x, y);
|
this->Render(1, 1, x, y);
|
||||||
} else if (key == '/') {
|
} else if (key == '/') {
|
||||||
this->SearchMode = true;
|
this->SetSearchMode(true);
|
||||||
this->UpdateStatusBar("Search");
|
this->UpdateStatusBar("Search");
|
||||||
this->PrintKeys(1);
|
this->PrintKeys(1);
|
||||||
touchwin(stdscr);
|
touchwin(stdscr);
|
||||||
|
@ -63,6 +63,8 @@ public:
|
|||||||
MAX_WIDTH = 512
|
MAX_WIDTH = 512
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void SetSearchMode(bool enable);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method should normally be called only by the form. The only
|
* This method should normally be called only by the form. The only
|
||||||
* exception is during a resize. The optional argument specifies the
|
* exception is during a resize. The optional argument specifies the
|
||||||
|
@ -32,6 +32,12 @@ cmCursesStringWidget::cmCursesStringWidget(int width, int height, int left,
|
|||||||
field_opts_off(this->Field, O_STATIC);
|
field_opts_off(this->Field, O_STATIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmCursesStringWidget::SetInEdit(bool inedit)
|
||||||
|
{
|
||||||
|
this->InEdit = inedit;
|
||||||
|
curs_set(inedit);
|
||||||
|
}
|
||||||
|
|
||||||
void cmCursesStringWidget::OnTab(cmCursesMainForm* /*unused*/,
|
void cmCursesStringWidget::OnTab(cmCursesMainForm* /*unused*/,
|
||||||
WINDOW* /*unused*/)
|
WINDOW* /*unused*/)
|
||||||
{
|
{
|
||||||
@ -42,7 +48,7 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
|
|||||||
{
|
{
|
||||||
if (this->InEdit) {
|
if (this->InEdit) {
|
||||||
cmCursesForm::LogMessage("String widget leaving edit.");
|
cmCursesForm::LogMessage("String widget leaving edit.");
|
||||||
this->InEdit = false;
|
this->SetInEdit(false);
|
||||||
fm->PrintKeys();
|
fm->PrintKeys();
|
||||||
this->OriginalString.clear();
|
this->OriginalString.clear();
|
||||||
// trick to force forms to update the field buffer
|
// trick to force forms to update the field buffer
|
||||||
@ -52,7 +58,7 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
|
|||||||
this->Done = true;
|
this->Done = true;
|
||||||
} else {
|
} else {
|
||||||
cmCursesForm::LogMessage("String widget entering edit.");
|
cmCursesForm::LogMessage("String widget entering edit.");
|
||||||
this->InEdit = true;
|
this->SetInEdit(true);
|
||||||
fm->PrintKeys();
|
fm->PrintKeys();
|
||||||
this->OriginalString = field_buffer(this->Field, 0);
|
this->OriginalString = field_buffer(this->Field, 0);
|
||||||
}
|
}
|
||||||
@ -114,7 +120,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||||||
} else if (key == KEY_DOWN || key == ctrl('n') || key == KEY_UP ||
|
} else if (key == KEY_DOWN || key == ctrl('n') || key == KEY_UP ||
|
||||||
key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') ||
|
key == ctrl('p') || key == KEY_NPAGE || key == ctrl('d') ||
|
||||||
key == KEY_PPAGE || key == ctrl('u')) {
|
key == KEY_PPAGE || key == ctrl('u')) {
|
||||||
this->InEdit = false;
|
this->SetInEdit(false);
|
||||||
this->OriginalString.clear();
|
this->OriginalString.clear();
|
||||||
// trick to force forms to update the field buffer
|
// trick to force forms to update the field buffer
|
||||||
form_driver(form, REQ_NEXT_FIELD);
|
form_driver(form, REQ_NEXT_FIELD);
|
||||||
@ -124,7 +130,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|||||||
// esc
|
// esc
|
||||||
else if (key == 27) {
|
else if (key == 27) {
|
||||||
if (this->InEdit) {
|
if (this->InEdit) {
|
||||||
this->InEdit = false;
|
this->SetInEdit(false);
|
||||||
fm->PrintKeys();
|
fm->PrintKeys();
|
||||||
this->SetString(this->OriginalString);
|
this->SetString(this->OriginalString);
|
||||||
this->OriginalString.clear();
|
this->OriginalString.clear();
|
||||||
|
@ -40,7 +40,7 @@ public:
|
|||||||
* Set/Get InEdit flag. Can be used to tell the widget to leave
|
* Set/Get InEdit flag. Can be used to tell the widget to leave
|
||||||
* edit mode (in case of a resize for example).
|
* edit mode (in case of a resize for example).
|
||||||
*/
|
*/
|
||||||
void SetInEdit(bool inedit) { this->InEdit = inedit; }
|
void SetInEdit(bool inedit);
|
||||||
bool GetInEdit() { return this->InEdit; }
|
bool GetInEdit() { return this->InEdit; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user