Patchwork [U-Boot,v2,3/4] New command clear: Clear the ANSI terminal

login
register
mail settings
Submitter Pali Rohár
Date Nov. 1, 2012, 11:39 a.m.
Message ID <1351769953-13560-4-git-send-email-pali.rohar@gmail.com>
Download mbox | patch
Permalink /patch/196170/
State Superseded
Delegated to: Anatolij Gustschin
Headers show

Comments

Pali Rohár - Nov. 1, 2012, 11:39 a.m.
This patch adding new simple command clear which clear ANSI terminal.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
Cc: Marcel Mol <marcel@mesa.nl>
---
This patch was in Nokia RX-51 patch series (v2).

Changes since RX-51 patch v2:
  - Removed from include/config_cmd_all.h
  - Removed ANSI escape codes (now in BootMenu command patch)

Changes since original version:
  - Renamed command clr to clear
  - Use puts instead printf
  - Move cursor to pos1,1

 common/Makefile    |    1 +
 common/cmd_clear.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+)
 create mode 100644 common/cmd_clear.c
Wolfgang Denk - Nov. 13, 2012, 8:09 a.m.
Dear Pali Rohár,

In message <1351769953-13560-4-git-send-email-pali.rohar@gmail.com> you wrote:
> This patch adding new simple command clear which clear ANSI terminal.


Please note that this duplicates or affects existing functionality;
for example, common/lcd.c implements the "cls" = Clear Screen
command.

If we add such more globnal support now, this should be unified (in a
backward compatible) way with the existing code.

Thanks.

Best regards,

Wolfgang Denk

Patch

diff --git a/common/Makefile b/common/Makefile
index 1435992..328ca49 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -70,6 +70,7 @@  COBJS-$(CONFIG_CMD_BMP) += cmd_bmp.o
 COBJS-$(CONFIG_CMD_BOOTMENU) += cmd_bootmenu.o
 COBJS-$(CONFIG_CMD_BOOTLDR) += cmd_bootldr.o
 COBJS-$(CONFIG_CMD_CACHE) += cmd_cache.o
+COBJS-$(CONFIG_CMD_CLEAR) += cmd_clear.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_clear.c b/common/cmd_clear.c
new file mode 100644
index 0000000..29b4718
--- /dev/null
+++ b/common/cmd_clear.c
@@ -0,0 +1,43 @@ 
+/*
+ * Copyright 2011
+ * Marcel Mol, MESA Consulting, marcel@mesa.nl
+ *
+ * Copyright 2011
+ * Pali Rohár, pali.rohar@gmail.com
+ *
+ * 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>
+#include <ansi.h>
+
+static int do_clear(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	puts(ANSI_CLEAR_CONSOLE);
+	printf(ANSI_CURSOR_POSITION, 1, 1);
+	return 0;
+}
+
+U_BOOT_CMD(
+	clear,    CONFIG_SYS_MAXARGS,     1,      do_clear,
+	"clear",
+	"\n"
+	"    - clear screen and move cursor to top of screen"
+);