API extension?: bool cMenuEditStrItem::InEditMode()
Commit Message
Christian Wieninger wrote:
> Hi,
>
> is there a chance to get a new member function like
>
> bool cMenuEditStrItem::InEditMode()
> {
> return pos > -1;
> }
>
> that returns the edit state on an item?
Ok, VDR 1.3.38 will be changed according to the attached patch.
Klaus
@@ -85,6 +85,8 @@
void SetHelpKeys(void);
virtual void Set(void);
char Inc(char c, bool Up);
+protected:
+ bool InEditMode(void) { return pos >= 0; }
public:
cMenuEditStrItem(const char *Name, char *Value, int Length, const char *Allowed);
~cMenuEditStrItem();
@@ -253,7 +253,7 @@
void cMenuEditStrItem::SetHelpKeys(void)
{
- if (pos >= 0)
+ if (InEditMode())
cSkinDisplay::Current()->SetButtons(tr("ABC/abc"), tr(insert ? "Overwrite" : "Insert"), tr("Delete"));
else
cSkinDisplay::Current()->SetButtons(NULL);
@@ -264,7 +264,7 @@
char buf[1000];
const char *fmt = insert && newchar ? "[]%c%s" : "[%c]%s";
- if (pos >= 0) {
+ if (InEditMode()) {
const cFont *font = cFont::GetFont(fontOsd);
strncpy(buf, value, pos);
snprintf(buf + pos, sizeof(buf) - pos - 2, fmt, *(value + pos), value + pos + 1);
@@ -322,7 +322,7 @@
{
switch (Key) {
case kRed: // Switch between upper- and lowercase characters
- if (pos >= 0) {
+ if (InEditMode()) {
if (!insert || !newchar) {
uppercase = !uppercase;
value[pos] = uppercase ? toupper(value[pos]) : tolower(value[pos]);
@@ -332,7 +332,7 @@
return osUnknown;
break;
case kGreen: // Toggle insert/overwrite modes
- if (pos >= 0) {
+ if (InEditMode()) {
insert = !insert;
newchar = true;
SetHelpKeys();
@@ -342,7 +342,7 @@
break;
case kYellow|k_Repeat:
case kYellow: // Remove the character at current position; in insert mode it is the character to the right of cursor
- if (pos >= 0) {
+ if (InEditMode()) {
if (strlen(value) > 1) {
if (!insert || pos < int(strlen(value)) - 1)
memmove(value + pos, value + pos + 1, strlen(value) - pos);
@@ -361,7 +361,7 @@
break;
case kBlue|k_Repeat:
case kBlue: // consume the key only if in edit-mode
- if (pos >= 0)
+ if (InEditMode())
;
else
return osUnknown;
@@ -395,7 +395,7 @@
case kUp|k_Repeat:
case kUp:
case kDown|k_Repeat:
- case kDown: if (pos >= 0) {
+ case kDown: if (InEditMode()) {
if (insert && newchar) {
// create a new character in insert mode
if (int(strlen(value)) < length - 1) {
@@ -412,7 +412,7 @@
else
return cMenuEditItem::ProcessKey(Key);
break;
- case kOk: if (pos >= 0) {
+ case kOk: if (InEditMode()) {
pos = -1;
newchar = true;
stripspace(value);
@@ -420,7 +420,7 @@
break;
}
// run into default
- default: if (pos >= 0 && BASICKEY(Key) == kKbd) {
+ default: if (InEditMode() && BASICKEY(Key) == kKbd) {
int c = KEYKBD(Key);
if (c <= 0xFF) {
const char *p = strchr(allowed, tolower(c));