mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-28 02:35:28 +00:00
Keys I keep hitting should work like I expect them to.
Home or Ctrl+A = move to beginning of line
End or Ctrl+E = move to end of line
Del = delete-right
Ctrl+K = delete to end of line
Ctrl+L = clear screen and reprint current line
Ctrl+N = next command
Ctrl+P = previous command
Also, improve filtering of escape sequences and non-printable
characters, so hitting unsupported keys or control codes doesn't mess
up the current line of input.
BUG=chrome-os-partner:11666
TEST=manual
type 'fhelpbar'
home -> cursor moves to beginning of line
Ctrl+E -> cursor moves to end of line
Ctrl+A -> cursor moves to beginning of line
(of course, if you're using Minicom, you'll need to type Ctrl+A A, since
Minicom uses Ctrl+A as its control key)
del -> 'helpbar'
end -> cursor moves to end of line
left-arrow 3 times -> cursor moves under 'b'
Ctrl+L -> screen clears, cursor still under 'b'
Ctrl+K -> 'help'
Ctrl+Y Page-Up Page-Down -> nothing printed
enter -> prints known commands (output of 'help' command)
Ctrl+P -> 'help'
Ctrl+N -> empty command line
Change-Id: Id893c93b26db8f3deed6ea8be5aab88a3daaead4
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/28143
94 lines
2.2 KiB
C
94 lines
2.2 KiB
C
/* Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
/* Various utility functions and macros */
|
|
|
|
#ifndef __CROS_EC_UTIL_H
|
|
#define __CROS_EC_UTIL_H
|
|
|
|
#include "common.h"
|
|
#include "config.h"
|
|
#include "panic.h"
|
|
|
|
/**
|
|
* Trigger a compilation failure if the condition
|
|
* is not verified at build time.
|
|
*/
|
|
#define BUILD_ASSERT(cond) ((void)sizeof(char[1 - 2*!(cond)]))
|
|
|
|
/**
|
|
* Trigger a debug exception if the condition
|
|
* is not verified at runtime.
|
|
*/
|
|
#ifdef CONFIG_DEBUG
|
|
# ifdef CONFIG_ASSERT_HELP
|
|
# define ASSERT(cond) do { \
|
|
if (!(cond)) \
|
|
panic_assert_fail(#cond, __func__, __FILE__, \
|
|
__LINE__); \
|
|
} while (0);
|
|
# else
|
|
# define ASSERT(cond) do { \
|
|
if (!(cond)) \
|
|
__asm("bkpt"); \
|
|
} while (0);
|
|
# endif
|
|
#else
|
|
#define ASSERT(cond)
|
|
#endif
|
|
|
|
|
|
/* Standard macros / definitions */
|
|
#ifndef ARRAY_SIZE
|
|
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
|
#endif
|
|
#ifndef MAX
|
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
|
#endif
|
|
#ifndef MIN
|
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
|
#endif
|
|
#ifndef NULL
|
|
#define NULL ((void *)0)
|
|
#endif
|
|
|
|
/**
|
|
* macros for integer division with various rounding variants
|
|
* default integer division rounds down.
|
|
*/
|
|
#define DIV_ROUND_UP(x, y) (((x) + ((y) - 1)) / (y))
|
|
#define DIV_ROUND_NEAREST(x, y) (((x) + ((y) / 2)) / (y))
|
|
|
|
/* Standard library functions */
|
|
int atoi(const char *nptr);
|
|
int isdigit(int c);
|
|
int isspace(int c);
|
|
int isalpha(int c);
|
|
int isprint(int c);
|
|
void *memcpy(void *dest, const void *src, int len);
|
|
void *memset(void *dest, int c, int len);
|
|
void *memmove(void *dest, const void *src, int len);
|
|
int strcasecmp(const char *s1, const char *s2);
|
|
int strncasecmp(const char *s1, const char *s2, int size);
|
|
int strlen(const char *s);
|
|
|
|
/* Like strtol(), but for integers. */
|
|
int strtoi(const char *nptr, char **endptr, int base);
|
|
|
|
/* Like strncpy(), but guarantees null termination. */
|
|
char *strzcpy(char *dest, const char *src, int len);
|
|
|
|
int tolower(int c);
|
|
|
|
/* 64-bit divide-and-modulo. Does the equivalent of:
|
|
*
|
|
* r = *n % d;
|
|
* *n /= d;
|
|
* return r;
|
|
*/
|
|
int uint64divmod(uint64_t *v, int by);
|
|
|
|
#endif /* __CROS_EC_UTIL_H */
|