/*
 * menu_search.c: A plugin for the Video Disk Recorder
 *
 * See the README file for copyright information and how to reach the author.
 *
 * $Id$
 */

#include <vdr/plugin.h>
#include "menu_search.h"

cMenuSearch::cMenuSearch(const char *Title, char *Text, eDvbFont Font):
   cOsdMenu(Title)
{
  szFilter = Text;
  newFilter = strdup(szFilter);
  Add(new cMenuEditStrItem(tr("Text to search"), newFilter, MaxFileName, tr(FileNameChars)));
  SetCols(strlen(tr("Text to search"))+3);
  SetHelp(tr("VDR"), NULL, NULL, NULL);
  Update();
}

cMenuSearch::~cMenuSearch(void)
{
  free(newFilter);
}

void cMenuSearch::Update(void)
{
  Display();
}

eOSState cMenuSearch::ProcessKey(eKeys Key)
{
  eOSState state = cOsdMenu::ProcessKey(Key);

  if (state == osUnknown) {
     switch (Key) {
     case kRed:    strn0cpy(newFilter, "vdr\[", MaxFileName);
                   break;
     case kOk:     strn0cpy(szFilter, newFilter, MaxFileName);
                   return osBack;
     default:      break;
     }
  }

  Update();
  return state;
}


