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

Implemented enhanced string editing

This commit is contained in:
Klaus Schmidinger 2002-04-13 10:52:01 +02:00
parent 37fa217a09
commit cba5ef4373
5 changed files with 154 additions and 27 deletions

View File

@ -202,6 +202,8 @@ Sergei Haller <Sergei.Haller@math.uni-giessen.de>
for adding the TPID to Hessen-3 in 'channels.conf' for adding the TPID to Hessen-3 in 'channels.conf'
for suggesting that the EPG scan should skip channels with their 'Ca' parameter for suggesting that the EPG scan should skip channels with their 'Ca' parameter
explicitly set to an other DVB card explicitly set to an other DVB card
for implementing enhanced string editing with upper-/lowercase, insert/overwrite
and delete
Andreas Gebel <andreas@xcapenet.de> Andreas Gebel <andreas@xcapenet.de>
for his help in keeping 'channels.conf' up to date for his help in keeping 'channels.conf' up to date

View File

@ -1195,3 +1195,5 @@ Video Disk Recorder Revision History
- Added some DVB-T channels for Berlin (Germany) to channels.conf.terr (thanks to - Added some DVB-T channels for Berlin (Germany) to channels.conf.terr (thanks to
Andreas Roedl). Andreas Roedl).
- Implemented enhanced string editing with upper-/lowercase, insert/overwrite
and delete (thanks to Sergei Haller).

14
MANUAL
View File

@ -17,9 +17,9 @@ Video Disk Recorder User's Manual
Ok Ch display Select Switch Edit Accept Play Progress disp. Ok Ch display Select Switch Edit Accept Play Progress disp.
Menu Menu on Menu off Menu off Menu off Menu off Menu off Menu on Menu Menu on Menu off Menu off Menu off Menu off Menu off Menu on
Back - Menu off VDR menu VDR menu Discard VDR menu Recordings menu Back - Menu off VDR menu VDR menu Discard VDR menu Recordings menu
Red - Record Edit Edit - Play Jump Red - Record Edit Edit ABC/abc Play Jump
Green - Language New New - Rewind Skip -60s Green - Language New New Ins/Ovr Rewind Skip -60s
Yellow - - Delete Delete - Delete Skip +60s Yellow - - Delete Delete Delete Delete Skip +60s
Blue - Stop/Resume Mark On/Off(1) - Summary Stop Blue - Stop/Resume Mark On/Off(1) - Summary Stop
0..9 Ch select - - - Numeric inp. - Editing 0..9 Ch select - - - Numeric inp. - Editing
@ -58,11 +58,9 @@ Video Disk Recorder User's Manual
by pressing the "Right" button (which puts brackets around the current by pressing the "Right" button (which puts brackets around the current
character as in "[R]TL"), selecting the desired character position with character as in "[R]TL"), selecting the desired character position with
"Left" and "Right", and changing the character with the "Up" and "Down" "Left" and "Right", and changing the character with the "Up" and "Down"
keys. "Ok" then confirms the changes. The special character '^' can be used keys. "Ok" then confirms the changes. The "Red" key toggles between
to "cut off" a string at this position. When this character is visible in the upper- and lowercase characters, while the "Green" key switches between
brackets (as in abc[^]), the next press to the "Left" or "Ok" button will insert and overwrite mode. The "Yellow" key deletes the current character.
actually cut off the string. Using "Up" and/or "Down" brings back the
original rest of the string (unless you have pressed "Left" or "Ok").
The "Red", "Green", "Yellow" and "Blue" buttons have special meanings The "Red", "Green", "Yellow" and "Blue" buttons have special meanings
in various menus and are listed at the bottom of the on-screen-display. in various menus and are listed at the bottom of the on-screen-display.

38
i18n.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: i18n.c 1.79 2002/04/06 09:49:19 kls Exp $ * $Id: i18n.c 1.80 2002/04/13 10:42:48 kls Exp $
* *
* Slovenian translations provided by Miha Setina <mihasetina@softhome.net> and Matjaz Thaler <matjaz.thaler@guest.arnes.si> * Slovenian translations provided by Miha Setina <mihasetina@softhome.net> and Matjaz Thaler <matjaz.thaler@guest.arnes.si>
* Italian translations provided by Alberto Carraro <bertocar@tin.it> * Italian translations provided by Alberto Carraro <bertocar@tin.it>
@ -467,6 +467,42 @@ const tPhrase Phrases[] = {
"Wyrzucenie", "Wyrzucenie",
"Eyectar", "Eyectar",
}, },
{ "ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
"ABC/abc",
},
{ "Insert",
"Einfügen",
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
},
{ "Overwrite",
"Überschreiben",
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
"",// TODO
},
// Confirmations: // Confirmations:
{ "Delete channel?", { "Delete channel?",
"Kanal löschen?", "Kanal löschen?",

125
menu.c
View File

@ -4,10 +4,11 @@
* 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: menu.c 1.182 2002/04/06 09:41:59 kls Exp $ * $Id: menu.c 1.183 2002/04/13 10:38:03 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
#include <ctype.h>
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
@ -23,7 +24,7 @@
#define CHNUMWIDTH (Channels.Count() > 999 ? 5 : 4) // there are people with more than 999 channels... #define CHNUMWIDTH (Channels.Count() > 999 ? 5 : 4) // there are people with more than 999 channels...
const char *FileNameChars = " aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789-.#~^"; const char *FileNameChars = " abcdefghijklmnopqrstuvwxyz0123456789-.#~";
// --- cMenuEditItem --------------------------------------------------------- // --- cMenuEditItem ---------------------------------------------------------
@ -515,6 +516,8 @@ private:
int length; int length;
const char *allowed; const char *allowed;
int pos; int pos;
bool insert, newchar, uppercase;
void SetHelpKeys(void);
virtual void Set(void); virtual void Set(void);
char Inc(char c, bool Up); char Inc(char c, bool Up);
public: public:
@ -530,6 +533,8 @@ cMenuEditStrItem::cMenuEditStrItem(const char *Name, char *Value, int Length, co
length = Length; length = Length;
allowed = strdup(Allowed); allowed = strdup(Allowed);
pos = -1; pos = -1;
insert = uppercase = false;
newchar = true;
Set(); Set();
} }
@ -538,17 +543,50 @@ cMenuEditStrItem::~cMenuEditStrItem()
delete allowed; delete allowed;
} }
void cMenuEditStrItem::SetHelpKeys(void)
{
if (pos >= 0)
Interface->Help(tr("ABC/abc"), tr(insert ? "Overwrite" : "Insert"), tr("Delete"));
else
Interface->Help(NULL);
}
void cMenuEditStrItem::Set(void) void cMenuEditStrItem::Set(void)
{ {
char buf[1000]; char buf[1000];
int max = 30; // this indicates, how many characters fit on the screen
// and has to be calculated on the fly (TODO)
const char *fmt = insert && newchar ? "[]%c%s" : "[%c]%s";
if (pos >= 0) { if (pos >= 0) {
strncpy(buf, value, pos); strncpy(buf, value, pos);
const char *s = value[pos] != '^' ? value + pos + 1 : ""; snprintf(buf + pos, sizeof(buf) - pos - 2, fmt, *(value + pos), value + pos + 1);
snprintf(buf + pos, sizeof(buf) - pos - 2, "[%c]%s", *(value + pos), s); if (int(strlen(buf)) <= max)
SetValue(buf);
else if (pos + 4 <= max) {
buf[max - 1] = '>';
buf[max] = 0;
SetValue(buf);
}
else if (buf[pos + 3]) {
buf[pos + 4 - max] = '<';
buf[pos + 3] = '>';
buf[pos + 4] = 0;
SetValue(buf + pos + 4 - max);
}
else {
buf[pos + 3 - max] = '<';
SetValue(buf + pos + 3 - max);
}
}
else if (int(strlen(value)) <= max)
SetValue(value);
else {
strncpy(buf, value, max - 1);
buf[max - 1] = '>';
buf[max] = 0;
SetValue(buf); SetValue(buf);
} }
else
SetValue(value);
} }
char cMenuEditStrItem::Inc(char c, bool Up) char cMenuEditStrItem::Inc(char c, bool Up)
@ -568,34 +606,85 @@ char cMenuEditStrItem::Inc(char c, bool Up)
eOSState cMenuEditStrItem::ProcessKey(eKeys Key) eOSState cMenuEditStrItem::ProcessKey(eKeys Key)
{ {
switch (Key) { switch (Key) {
case kLeft|k_Repeat: case kRed: // Switch between upper- and lowercase characters
case kLeft: if (pos > 0) { if (pos >= 0 && (!insert || !newchar)) {
if (value[pos] == '^') uppercase = !uppercase;
value[pos] = 0; value[pos] = uppercase ? toupper(value[pos]) : tolower(value[pos]);
pos--;
} }
break; break;
case kGreen: // Toggle insert/overwrite modes
if (pos >= 0) {
insert = !insert;
newchar = true;
}
SetHelpKeys();
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 (strlen(value) > 1) {
memmove(value + pos, value + pos + 1, strlen(value) - pos);
// reduce position, if we removed the last character
if (pos == int(strlen(value)))
pos--;
}
else if (strlen(value) == 1)
value[0] = ' '; // This is the last character in the string, replace it with a blank
if (isalpha(value[pos]))
uppercase = isupper(value[pos]);
newchar = true;
}
break;
case kLeft|k_Repeat:
case kLeft: if (pos > 0) {
if (!insert || newchar)
pos--;
newchar = true;
}
if (!insert && isalpha(value[pos]))
uppercase = isupper(value[pos]);
break;
case kRight|k_Repeat: case kRight|k_Repeat:
case kRight: if (pos < length && value[pos] != '^' && (pos < int(strlen(value) - 1) || value[pos] != ' ')) { case kRight: if (pos < length && pos < int(strlen(value)) ) {
if (++pos >= int(strlen(value))) { if (++pos >= int(strlen(value))) {
value[pos] = ' '; if (pos == 0 || value[pos - 1] != ' ') {
value[pos + 1] = 0; value[pos] = ' ';
value[pos + 1] = 0;
}
else
pos--; // allow only blank at the end
} }
} }
newchar = true;
if (!insert && isalpha(value[pos]))
uppercase = isupper(value[pos]);
SetHelpKeys();
break; break;
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 (pos >= 0) {
value[pos] = Inc(value[pos], NORMALKEY(Key) == kUp); if (insert && newchar) {
// create a new character in insert mode
if (int(strlen(value)) < length) {
memmove(value + pos + 1, value + pos, strlen(value) - pos + 1);
value[pos] = ' ';
}
}
if (uppercase)
value[pos] = toupper(Inc(tolower(value[pos]), NORMALKEY(Key) == kUp));
else
value[pos] = Inc( value[pos], NORMALKEY(Key) == kUp);
newchar = false;
}
else else
return cMenuEditItem::ProcessKey(Key); return cMenuEditItem::ProcessKey(Key);
break; break;
case kOk: if (pos >= 0) { case kOk: if (pos >= 0) {
if (value[pos] == '^')
value[pos] = 0;
pos = -1; pos = -1;
newchar = true;
stripspace(value); stripspace(value);
SetHelpKeys();
break; break;
} }
// run into default // run into default