/*
* GRUB -- GRand Unified Bootloader
* Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2007,2009 Free Software Foundation, Inc.
*
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* GRUB is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
*/
#include <grub/partition.h>
static int hist_size;
static int hist_pos = 0;
static int hist_end = 0;
static int hist_used = 0;
{
/* Copy the old lines into the new buffer. */
if (old_hist_lines)
{
/* Remove the lines that don't fit in the new buffer. */
{
int i;
for (i = 1; i <= delsize; i++)
{
if (pos < 0)
}
if (hist_end < 0)
}
else if (hist_used)
{
/* Copy the older part. */
/* Copy the newer part. */
hist_end * sizeof (grub_uint32_t *));
}
}
hist_pos = 0;
return 0;
}
/* Get the entry POS from the history where `0' is the newest
entry. */
static grub_uint32_t *
{
return hist_lines[pos];
}
static grub_size_t
{
const grub_uint32_t *p = s;
while (*p)
p++;
return p - s;
}
/* Replace the history entry on position POS with the string S. */
static void
{
if (!hist_lines[pos])
{
grub_print_error ();
return ;
}
}
/* Insert a new history line S on the top of the history. */
static void
{
/* Remove the oldest entry in the history to make room for a new
entry. */
{
hist_end--;
if (hist_end < 0)
}
else
hist_used++;
/* Move to the next position. */
hist_pos--;
if (hist_pos < 0)
/* Insert into history. */
}
/* Replace the history entry on position POS with the string S. */
static void
{
}
/* A completion hook to print items. */
static void
{
if (count == 0)
{
/* If this is the first time, print a label. */
grub_puts ("");
switch (type)
{
break;
break;
break;
break;
break;
default:
break;
}
grub_puts ("");
}
if (type == GRUB_COMPLETION_TYPE_PARTITION)
{
}
else
}
struct cmdline_term
{
};
/* Get a command-line. If ESC is pushed, return zero,
otherwise return command line. */
/* FIXME: The dumb interface is not supported yet. */
char *
{
int key;
int histpos = 0;
grub_uint32_t c);
auto void cl_set_pos_all (void);
auto void init_clterm_all (void);
char *ret;
unsigned nterms;
{
}
void cl_set_pos_all (void)
{
unsigned i;
for (i = 0; i < nterms; i++)
cl_set_pos (&cl_terms[i]);
}
inline void __attribute__ ((always_inline)) cl_print (struct cmdline_term *cl_term, int pos, grub_uint32_t c)
{
grub_uint32_t *p;
{
if (c)
else
{
else
}
}
}
{
unsigned i;
for (i = 0; i < nterms; i++)
}
{
{
max_len *= 2;
if (nbuf)
else
{
grub_print_error ();
max_len /= 2;
}
}
{
cl_set_pos_all ();
cl_print_all (lpos, 0);
cl_set_pos_all ();
}
}
{
{
cl_set_pos_all ();
lpos = saved_lpos;
cl_set_pos_all ();
cl_print_all (lpos, 0);
cl_set_pos_all ();
}
}
{
}
void init_clterm_all (void)
{
unsigned i;
for (i = 0; i < nterms; i++)
init_clterm (&cl_terms[i]);
}
if (!buf)
return 0;
buf[0] = '\0';
{
}
{
nterms = 0;
nterms++;
if (!cl_terms)
return 0;
{
cl_term_cur++;
}
}
if (hist_used == 0)
grub_refresh ();
{
switch (key)
{
case GRUB_TERM_CTRL | 'a':
case GRUB_TERM_KEY_HOME:
lpos = 0;
cl_set_pos_all ();
break;
case GRUB_TERM_CTRL | 'b':
case GRUB_TERM_KEY_LEFT:
if (lpos > 0)
{
lpos--;
cl_set_pos_all ();
}
break;
case GRUB_TERM_CTRL | 'e':
case GRUB_TERM_KEY_END:
cl_set_pos_all ();
break;
case GRUB_TERM_CTRL | 'f':
case GRUB_TERM_KEY_RIGHT:
{
lpos++;
cl_set_pos_all ();
}
break;
case GRUB_TERM_CTRL | 'i':
case '\t':
{
int restore;
char *insertu8;
char *bufu8;
if (!bufu8)
{
grub_print_error ();
break;
}
if (restore)
{
/* Restore the prompt. */
init_clterm_all ();
cl_print_all (0, 0);
}
if (insertu8)
{
grub_ssize_t t;
if (!insert)
{
grub_print_error ();
break;
}
(grub_uint8_t *) insertu8,
insertlen, 0);
if (t > 0)
{
{
insert[t-1] = 0;
if (t != 1)
lpos++;
}
else
{
insert[t] = 0;
}
}
}
cl_set_pos_all ();
}
break;
case GRUB_TERM_CTRL | 'k':
{
* sizeof (grub_uint32_t));
if (grub_errno)
{
grub_print_error ();
}
else
{
}
}
break;
case GRUB_TERM_CTRL | 'n':
case GRUB_TERM_KEY_DOWN:
{
lpos = 0;
if (histpos > 0)
{
histpos--;
}
break;
}
case GRUB_TERM_KEY_UP:
case GRUB_TERM_CTRL | 'p':
{
lpos = 0;
{
histpos++;
}
}
break;
case GRUB_TERM_CTRL | 'u':
if (lpos > 0)
{
grub_size_t n = lpos;
if (grub_errno)
{
grub_print_error ();
}
if (kill_buf)
{
kill_buf[n] = '\0';
}
lpos = 0;
cl_set_pos_all ();
cl_delete (n);
}
break;
case GRUB_TERM_CTRL | 'y':
if (kill_buf)
break;
case '\e':
return 0;
case '\b':
if (lpos > 0)
{
lpos--;
cl_set_pos_all ();
}
else
break;
/* fall through */
case GRUB_TERM_CTRL | 'd':
case GRUB_TERM_KEY_DC:
cl_delete (1);
break;
default:
if (grub_isprint (key))
{
}
break;
}
grub_refresh ();
}
grub_xputs ("\n");
grub_refresh ();
/* Remove leading spaces. */
lpos = 0;
lpos++;
histpos = 0;
if (strlen_ucs4 (buf) > 0)
{
grub_history_add (empty, 0);
}
return ret;
}