|
@@ -9,7 +9,6 @@
|
|
|
#include "cmStateTypes.h"
|
|
#include "cmStateTypes.h"
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
#include <cstdio>
|
|
|
-#include <cstring>
|
|
|
|
|
|
|
|
|
|
inline int ctrl(int z)
|
|
inline int ctrl(int z)
|
|
|
{
|
|
{
|
|
@@ -35,13 +34,13 @@ void cmCursesStringWidget::OnTab(cmCursesMainForm* /*unused*/,
|
|
|
|
|
|
|
|
void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
|
|
void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
|
|
|
{
|
|
{
|
|
|
- FORM* form = fm->GetForm();
|
|
|
|
|
if (this->InEdit) {
|
|
if (this->InEdit) {
|
|
|
cmCursesForm::LogMessage("String widget leaving edit.");
|
|
cmCursesForm::LogMessage("String widget leaving edit.");
|
|
|
this->InEdit = false;
|
|
this->InEdit = false;
|
|
|
fm->PrintKeys();
|
|
fm->PrintKeys();
|
|
|
- delete[] this->OriginalString;
|
|
|
|
|
|
|
+ this->OriginalString.clear();
|
|
|
// trick to force forms to update the field buffer
|
|
// trick to force forms to update the field buffer
|
|
|
|
|
+ FORM* form = fm->GetForm();
|
|
|
form_driver(form, REQ_NEXT_FIELD);
|
|
form_driver(form, REQ_NEXT_FIELD);
|
|
|
form_driver(form, REQ_PREV_FIELD);
|
|
form_driver(form, REQ_PREV_FIELD);
|
|
|
this->Done = true;
|
|
this->Done = true;
|
|
@@ -49,9 +48,7 @@ void cmCursesStringWidget::OnReturn(cmCursesMainForm* fm, WINDOW* /*unused*/)
|
|
|
cmCursesForm::LogMessage("String widget entering edit.");
|
|
cmCursesForm::LogMessage("String widget entering edit.");
|
|
|
this->InEdit = true;
|
|
this->InEdit = true;
|
|
|
fm->PrintKeys();
|
|
fm->PrintKeys();
|
|
|
- char* buf = field_buffer(this->Field, 0);
|
|
|
|
|
- this->OriginalString = new char[strlen(buf) + 1];
|
|
|
|
|
- strcpy(this->OriginalString, buf);
|
|
|
|
|
|
|
+ this->OriginalString = field_buffer(this->Field, 0);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -75,7 +72,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- this->OriginalString = nullptr;
|
|
|
|
|
|
|
+ this->OriginalString.clear();
|
|
|
this->Done = false;
|
|
this->Done = false;
|
|
|
|
|
|
|
|
char debugMessage[128];
|
|
char debugMessage[128];
|
|
@@ -113,7 +110,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|
|
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->InEdit = false;
|
|
|
- delete[] this->OriginalString;
|
|
|
|
|
|
|
+ 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);
|
|
|
form_driver(form, REQ_PREV_FIELD);
|
|
form_driver(form, REQ_PREV_FIELD);
|
|
@@ -125,7 +122,7 @@ bool cmCursesStringWidget::HandleInput(int& key, cmCursesMainForm* fm,
|
|
|
this->InEdit = false;
|
|
this->InEdit = false;
|
|
|
fm->PrintKeys();
|
|
fm->PrintKeys();
|
|
|
this->SetString(this->OriginalString);
|
|
this->SetString(this->OriginalString);
|
|
|
- delete[] this->OriginalString;
|
|
|
|
|
|
|
+ this->OriginalString.clear();
|
|
|
touchwin(w);
|
|
touchwin(w);
|
|
|
wrefresh(w);
|
|
wrefresh(w);
|
|
|
return true;
|
|
return true;
|
|
@@ -188,23 +185,18 @@ bool cmCursesStringWidget::PrintKeys()
|
|
|
}
|
|
}
|
|
|
if (this->InEdit) {
|
|
if (this->InEdit) {
|
|
|
char fmt_s[] = "%s";
|
|
char fmt_s[] = "%s";
|
|
|
- char firstLine[512];
|
|
|
|
|
// Clean the toolbar
|
|
// Clean the toolbar
|
|
|
- memset(firstLine, ' ', sizeof(firstLine));
|
|
|
|
|
- firstLine[511] = '\0';
|
|
|
|
|
curses_move(y - 4, 0);
|
|
curses_move(y - 4, 0);
|
|
|
- printw(fmt_s, firstLine);
|
|
|
|
|
- curses_move(y - 3, 0);
|
|
|
|
|
- printw(fmt_s, firstLine);
|
|
|
|
|
- curses_move(y - 2, 0);
|
|
|
|
|
- printw(fmt_s, firstLine);
|
|
|
|
|
- curses_move(y - 1, 0);
|
|
|
|
|
- printw(fmt_s, firstLine);
|
|
|
|
|
-
|
|
|
|
|
|
|
+ clrtoeol();
|
|
|
curses_move(y - 3, 0);
|
|
curses_move(y - 3, 0);
|
|
|
printw(fmt_s, "Editing option, press [enter] to confirm");
|
|
printw(fmt_s, "Editing option, press [enter] to confirm");
|
|
|
|
|
+ clrtoeol();
|
|
|
curses_move(y - 2, 0);
|
|
curses_move(y - 2, 0);
|
|
|
printw(fmt_s, " press [esc] to cancel");
|
|
printw(fmt_s, " press [esc] to cancel");
|
|
|
|
|
+ clrtoeol();
|
|
|
|
|
+ curses_move(y - 1, 0);
|
|
|
|
|
+ clrtoeol();
|
|
|
|
|
+
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
return false;
|
|
return false;
|