summaryrefslogtreecommitdiff
path: root/common/util.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2012-07-22 16:16:01 -0700
committerGerrit <chrome-bot@google.com>2012-07-23 11:03:33 -0700
commite27e2f02292bc825379ba914e43e13569ec738eb (patch)
treefa9fdae3658f4614bb24395126349597539d963c /common/util.c
parent085b31222b9f34e5470031fe1e957804beded69d (diff)
downloadchrome-ec-e27e2f02292bc825379ba914e43e13569ec738eb.tar.gz
Add console functionality
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
Diffstat (limited to 'common/util.c')
-rw-r--r--common/util.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/common/util.c b/common/util.c
index 69cdf1db64..008dc3843a 100644
--- a/common/util.c
+++ b/common/util.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved.
+/* 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.
*/
@@ -35,6 +35,10 @@ int isalpha(int c)
return (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z');
}
+int isprint(int c)
+{
+ return c >= ' ' && c <= '~';
+}
int tolower(int c)
{