diff mbox

[U-Boot,11/16] New command clr: Clear the ANSI terminal

Message ID 1324141398-14859-11-git-send-email-pali.rohar@gmail.com
State Changes Requested
Headers show

Commit Message

Pali Rohár Dec. 17, 2011, 5:03 p.m. UTC
From: Marcel Mol <marcel@mesa.nl>

 * Command can be enabled by CONFIG_CMD_CLR

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
---
 common/Makefile          |    1 +
 common/cmd_clr.c         |   38 ++++++++++++++++++++++++++++++++++++++
 include/config_cmd_all.h |    1 +
 3 files changed, 40 insertions(+), 0 deletions(-)
 create mode 100644 common/cmd_clr.c

Comments

Mike Frysinger Dec. 18, 2011, 6:56 p.m. UTC | #1
On Saturday 17 December 2011 12:03:13 Pali Rohár wrote:
> --- /dev/null
> +++ b/common/cmd_clr.c
>
> +int do_clr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])

static

> +	printf(ANSI_CLEAR_CONSOLE);

puts()

> +U_BOOT_CMD(
> +	clr,    CONFIG_SYS_MAXARGS,     1,      do_clr,
> +	"clr",
> +	"\n"
> +	"    - clear screen and move cursor to top of screen"
> +);

"clr" is unusual.  name it "clear" instead.  that's what all the standard *nix 
systems use after all.
-mike
Pali Rohár Dec. 18, 2011, 7:20 p.m. UTC | #2
On Sunday 18 December 2011 13:56:12 Mike Frysinger wrote:
> On Saturday 17 December 2011 12:03:13 Pali Rohár wrote:
> > --- /dev/null
> > +++ b/common/cmd_clr.c
> > 
> > +int do_clr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> 
> static
> 
> > +	printf(ANSI_CLEAR_CONSOLE);
> 
> puts()

puts(s) will output s + '\n'. And we do not want newline after clear screen.

> 
> > +U_BOOT_CMD(
> > +	clr,    CONFIG_SYS_MAXARGS,     1,      do_clr,
> > +	"clr",
> > +	"\n"
> > +	"    - clear screen and move cursor to top of screen"
> > +);
> 
> "clr" is unusual.  name it "clear" instead.  that's what all the standard
> *nix systems use after all.
> -mike

ok, I will rename clr to clear.
Mike Frysinger Dec. 18, 2011, 8:07 p.m. UTC | #3
On Sunday 18 December 2011 14:20:35 Pali Rohár wrote:
> On Sunday 18 December 2011 13:56:12 Mike Frysinger wrote:
> > On Saturday 17 December 2011 12:03:13 Pali Rohár wrote:
> > > --- /dev/null
> > > +++ b/common/cmd_clr.c
> > > 
> > > +int do_clr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> > 
> > static
> > 
> > > +	printf(ANSI_CLEAR_CONSOLE);
> > 
> > puts()
> 
> puts(s) will output s + '\n'. And we do not want newline after clear
> screen.

no it won't.  u-boot's puts() is diff from the POSIX puts().
-mike
diff mbox

Patch

diff --git a/common/Makefile b/common/Makefile
index 2d9ae8c..0552f19 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -69,6 +69,7 @@  COBJS-$(CONFIG_CMD_BEDBUG) += bedbug.o cmd_bedbug.o
 COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
+COBJS-$(CONFIG_CMD_CLR) += cmd_clr.o
 COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
diff --git a/common/cmd_clr.c b/common/cmd_clr.c
new file mode 100644
index 0000000..5077bbb
--- /dev/null
+++ b/common/cmd_clr.c
@@ -0,0 +1,38 @@ 
+/*
+ * Copyright 2011
+ * Marcel Mol, MESA Consulting, marcel@mesa.nl
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program 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 this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+
+int do_clr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	printf(ANSI_CLEAR_CONSOLE);
+	return 0;
+}
+
+U_BOOT_CMD(
+	clr,    CONFIG_SYS_MAXARGS,     1,      do_clr,
+	"clr",
+	"\n"
+	"    - clear screen and move cursor to top of screen"
+);
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index 9716f9c..f3c49ed 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -23,6 +23,7 @@ 
 #define CONFIG_CMD_BSP		/* Board Specific functions	*/
 #define CONFIG_CMD_CACHE	/* icache, dcache		*/
 #define CONFIG_CMD_CDP		/* Cisco Discovery Protocol	*/
+#define CONFIG_CMD_CLR		/* ANSI clear screen command	*/
 #define CONFIG_CMD_CONSOLE	/* coninfo			*/
 #define CONFIG_CMD_DATE		/* support for RTC, date/time...*/
 #define CONFIG_CMD_DHCP		/* DHCP Support			*/