summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2006-01-03 12:50:58 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2006-01-03 12:50:58 +0100
commit1f44f9adc25120b2eac99dc3fc17a0a1f09bb928 (patch)
tree4db21a5f0aa0b1dd4690bdbdebb58574def9bada
parenta9eed7bb7c6e5d92fe9be1d4aa090d17e971ab75 (diff)
downloadvdr-1f44f9adc25120b2eac99dc3fc17a0a1f09bb928.tar.gz
vdr-1f44f9adc25120b2eac99dc3fc17a0a1f09bb928.tar.bz2
Added cMenuEditStrItem::InEditMode()
-rw-r--r--CONTRIBUTORS3
-rw-r--r--HISTORY1
-rw-r--r--menuitems.c20
-rw-r--r--menuitems.h4
4 files changed, 17 insertions, 11 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 52ae691a..c469f1d0 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -1596,3 +1596,6 @@ Javier Fernández-Sanguino Peña <jfs@computer.org>
Jürgen Schneider <ivory7@gmx.de>
for a patch that was used as a base to fix handling multi byte key sequences
in cKbdRemote
+
+Christian Wieninger <cwieninger@gmx.de>
+ for suggesting to add cMenuEditStrItem::InEditMode()
diff --git a/HISTORY b/HISTORY
index f7ee13a6..a708a4fb 100644
--- a/HISTORY
+++ b/HISTORY
@@ -4072,3 +4072,4 @@ Video Disk Recorder Revision History
- Fixed setting the main thread id if VDR is running as a daemon.
- Fixed handling TS packets in cTS2PES (thanks to Reinhard Nissl).
- Added cTimer::SetPriority() to set a timer's priority (suggested by Kendy Kutzner).
+- Added cMenuEditStrItem::InEditMode() (suggested by Christian Wieninger).
diff --git a/menuitems.c b/menuitems.c
index 01fd6b3b..77f532c1 100644
--- a/menuitems.c
+++ b/menuitems.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.c 1.24 2005/11/11 13:26:00 kls Exp $
+ * $Id: menuitems.c 1.25 2006/01/03 12:47:39 kls Exp $
*/
#include "menuitems.h"
@@ -253,7 +253,7 @@ cMenuEditStrItem::~cMenuEditStrItem()
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 @@ void cMenuEditStrItem::Set(void)
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
{
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
return osUnknown;
break;
case kGreen: // Toggle insert/overwrite modes
- if (pos >= 0) {
+ if (InEditMode()) {
insert = !insert;
newchar = true;
SetHelpKeys();
@@ -342,7 +342,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
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 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
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));
diff --git a/menuitems.h b/menuitems.h
index f9afc151..c54f147e 100644
--- a/menuitems.h
+++ b/menuitems.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menuitems.h 1.12 2005/11/11 13:26:51 kls Exp $
+ * $Id: menuitems.h 1.13 2006/01/03 12:45:38 kls Exp $
*/
#ifndef __MENUITEMS_H
@@ -85,6 +85,8 @@ private:
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();