1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Added cMenuEditStrItem::InEditMode()

This commit is contained in:
Klaus Schmidinger 2006-01-03 12:50:58 +01:00
parent a9eed7bb7c
commit 1f44f9adc2
4 changed files with 17 additions and 11 deletions

View File

@ -1596,3 +1596,6 @@ Javier Fern
Jürgen Schneider <ivory7@gmx.de> Jürgen Schneider <ivory7@gmx.de>
for a patch that was used as a base to fix handling multi byte key sequences for a patch that was used as a base to fix handling multi byte key sequences
in cKbdRemote in cKbdRemote
Christian Wieninger <cwieninger@gmx.de>
for suggesting to add cMenuEditStrItem::InEditMode()

View File

@ -4072,3 +4072,4 @@ Video Disk Recorder Revision History
- Fixed setting the main thread id if VDR is running as a daemon. - Fixed setting the main thread id if VDR is running as a daemon.
- Fixed handling TS packets in cTS2PES (thanks to Reinhard Nissl). - Fixed handling TS packets in cTS2PES (thanks to Reinhard Nissl).
- Added cTimer::SetPriority() to set a timer's priority (suggested by Kendy Kutzner). - Added cTimer::SetPriority() to set a timer's priority (suggested by Kendy Kutzner).
- Added cMenuEditStrItem::InEditMode() (suggested by Christian Wieninger).

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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" #include "menuitems.h"
@ -253,7 +253,7 @@ cMenuEditStrItem::~cMenuEditStrItem()
void cMenuEditStrItem::SetHelpKeys(void) void cMenuEditStrItem::SetHelpKeys(void)
{ {
if (pos >= 0) if (InEditMode())
cSkinDisplay::Current()->SetButtons(tr("ABC/abc"), tr(insert ? "Overwrite" : "Insert"), tr("Delete")); cSkinDisplay::Current()->SetButtons(tr("ABC/abc"), tr(insert ? "Overwrite" : "Insert"), tr("Delete"));
else else
cSkinDisplay::Current()->SetButtons(NULL); cSkinDisplay::Current()->SetButtons(NULL);
@ -264,7 +264,7 @@ void cMenuEditStrItem::Set(void)
char buf[1000]; char buf[1000];
const char *fmt = insert && newchar ? "[]%c%s" : "[%c]%s"; const char *fmt = insert && newchar ? "[]%c%s" : "[%c]%s";
if (pos >= 0) { if (InEditMode()) {
const cFont *font = cFont::GetFont(fontOsd); const cFont *font = cFont::GetFont(fontOsd);
strncpy(buf, value, pos); strncpy(buf, value, pos);
snprintf(buf + pos, sizeof(buf) - pos - 2, fmt, *(value + pos), value + pos + 1); snprintf(buf + pos, sizeof(buf) - pos - 2, fmt, *(value + pos), value + pos + 1);
@ -322,7 +322,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
{ {
switch (Key) { switch (Key) {
case kRed: // Switch between upper- and lowercase characters case kRed: // Switch between upper- and lowercase characters
if (pos >= 0) { if (InEditMode()) {
if (!insert || !newchar) { if (!insert || !newchar) {
uppercase = !uppercase; uppercase = !uppercase;
value[pos] = uppercase ? toupper(value[pos]) : tolower(value[pos]); value[pos] = uppercase ? toupper(value[pos]) : tolower(value[pos]);
@ -332,7 +332,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
return osUnknown; return osUnknown;
break; break;
case kGreen: // Toggle insert/overwrite modes case kGreen: // Toggle insert/overwrite modes
if (pos >= 0) { if (InEditMode()) {
insert = !insert; insert = !insert;
newchar = true; newchar = true;
SetHelpKeys(); SetHelpKeys();
@ -342,7 +342,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
break; break;
case kYellow|k_Repeat: case kYellow|k_Repeat:
case kYellow: // Remove the character at current position; in insert mode it is the character to the right of cursor 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 (strlen(value) > 1) {
if (!insert || pos < int(strlen(value)) - 1) if (!insert || pos < int(strlen(value)) - 1)
memmove(value + pos, value + pos + 1, strlen(value) - pos); memmove(value + pos, value + pos + 1, strlen(value) - pos);
@ -361,7 +361,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
break; break;
case kBlue|k_Repeat: case kBlue|k_Repeat:
case kBlue: // consume the key only if in edit-mode case kBlue: // consume the key only if in edit-mode
if (pos >= 0) if (InEditMode())
; ;
else else
return osUnknown; return osUnknown;
@ -395,7 +395,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
case kUp|k_Repeat: case kUp|k_Repeat:
case kUp: case kUp:
case kDown|k_Repeat: case kDown|k_Repeat:
case kDown: if (pos >= 0) { case kDown: if (InEditMode()) {
if (insert && newchar) { if (insert && newchar) {
// create a new character in insert mode // create a new character in insert mode
if (int(strlen(value)) < length - 1) { if (int(strlen(value)) < length - 1) {
@ -412,7 +412,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
else else
return cMenuEditItem::ProcessKey(Key); return cMenuEditItem::ProcessKey(Key);
break; break;
case kOk: if (pos >= 0) { case kOk: if (InEditMode()) {
pos = -1; pos = -1;
newchar = true; newchar = true;
stripspace(value); stripspace(value);
@ -420,7 +420,7 @@ eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
break; break;
} }
// run into default // run into default
default: if (pos >= 0 && BASICKEY(Key) == kKbd) { default: if (InEditMode() && BASICKEY(Key) == kKbd) {
int c = KEYKBD(Key); int c = KEYKBD(Key);
if (c <= 0xFF) { if (c <= 0xFF) {
const char *p = strchr(allowed, tolower(c)); const char *p = strchr(allowed, tolower(c));

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * 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 #ifndef __MENUITEMS_H
@ -85,6 +85,8 @@ private:
void SetHelpKeys(void); void SetHelpKeys(void);
virtual void Set(void); virtual void Set(void);
char Inc(char c, bool Up); char Inc(char c, bool Up);
protected:
bool InEditMode(void) { return pos >= 0; }
public: public:
cMenuEditStrItem(const char *Name, char *Value, int Length, const char *Allowed); cMenuEditStrItem(const char *Name, char *Value, int Length, const char *Allowed);
~cMenuEditStrItem(); ~cMenuEditStrItem();