From patchwork Sat Apr 28 17:26:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Pali_Roh=C3=A1r?= X-Patchwork-Id: 155684 X-Patchwork-Delegate: agust@denx.de Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 2D05DB6FD8 for ; Sun, 29 Apr 2012 03:28:57 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id B763A282D4; Sat, 28 Apr 2012 19:28:38 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JKXeFmLjNQcX; Sat, 28 Apr 2012 19:28:38 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 2FE8028300; Sat, 28 Apr 2012 19:27:54 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 99C7328126 for ; Sat, 28 Apr 2012 19:27:43 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ixx3mqbiYh1i for ; Sat, 28 Apr 2012 19:27:42 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-wi0-f180.google.com (mail-wi0-f180.google.com [209.85.212.180]) by theia.denx.de (Postfix) with ESMTPS id 0B8BB28111 for ; Sat, 28 Apr 2012 19:27:19 +0200 (CEST) Received: by mail-wi0-f180.google.com with SMTP id hm17so1420190wib.9 for ; Sat, 28 Apr 2012 10:27:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=Qxny0tTHwVi+mwQ6xgH4s+9Q9v49ZX04MAxQZtmbI4o=; b=e4bh+I/dtOf/3diyjn2tXNfmmKpo2qGLGsXMXr9w6UnOJFT2hinb212CvuUw1LP5/A NXEklaEcw7FcEIM2ZZ7nBtBUIQqdkvJ5ZwReeNhIqNx63HHPMq7WddehcfkvpOMuVxYZ j6lcqDcSN2pQDm3WuHRqOQh1h+zw43cXaRmoc6TikogTeGqOxKQseiw4cPNHOQ8augr0 sySw1U75zxBnsNC8YKaoYh0dYSGTzJnWljQeztUv3VAVZakp+J81s03jlrfX5dQ0jgQA 7k3pRbUK4dszVVNLApwlys0um99DCBEFuFcRrrfacnMa2hglhq+uTvvHZYsnO8r710dt yNtg== Received: by 10.180.94.7 with SMTP id cy7mr18193908wib.3.1335634039339; Sat, 28 Apr 2012 10:27:19 -0700 (PDT) Received: from Pali-EliteBook.kolej.mff.cuni.cz (atrey.karlin.mff.cuni.cz. [195.113.26.193]) by mx.google.com with ESMTPS id w10sm22440738wiy.3.2012.04.28.10.27.18 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 28 Apr 2012 10:27:18 -0700 (PDT) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Sat, 28 Apr 2012 19:26:49 +0200 Message-Id: <1335634011-9104-10-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1335634011-9104-1-git-send-email-pali.rohar@gmail.com> References: <1335634011-9104-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Cc: marcel@mesa.nl, =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH v2 09/11] New command clear: Clear the ANSI terminal X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de * Command can be enabled by CONFIG_CMD_CLEAR * Added some ANSI escape codes definitions in common.h Signed-off-by: Pali Rohár Cc: Marcel Mol --- Changes since original version: - Renamed command clr to clear - Use puts instead printf - Move cursor to pos1,1 - Merged parts of patch "Add some ANSI escape codes definitions in common.h" common/Makefile | 1 + common/cmd_clear.c | 42 ++++++++++++++++++++++++++++++++++++++++++ include/common.h | 7 +++++++ include/config_cmd_all.h | 1 + 4 files changed, 51 insertions(+) create mode 100644 common/cmd_clear.c diff --git a/common/Makefile b/common/Makefile index d9f10f3..0682a49 100644 --- a/common/Makefile +++ b/common/Makefile @@ -70,6 +70,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_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..597611e --- /dev/null +++ b/common/cmd_clear.c @@ -0,0 +1,42 @@ +/* + * 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 +#include + +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" +); diff --git a/include/common.h b/include/common.h index 4b5841e..26bfd95 100644 --- a/include/common.h +++ b/include/common.h @@ -743,6 +743,13 @@ void clear_ctrlc (void); /* clear the Control-C condition */ int disable_ctrlc (int); /* 1 to disable, 0 to enable Control-C detect */ /* + * ANSI terminal + */ + +#define ANSI_CURSOR_POSITION "\e[%d;%dH" +#define ANSI_CLEAR_CONSOLE "\e[2J" + +/* * STDIO based functions (can always be used) */ /* serial stuff */ diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h index 2c6b829..243098a 100644 --- a/include/config_cmd_all.h +++ b/include/config_cmd_all.h @@ -24,6 +24,7 @@ #define CONFIG_CMD_BSP /* Board Specific functions */ #define CONFIG_CMD_CACHE /* icache, dcache */ #define CONFIG_CMD_CDP /* Cisco Discovery Protocol */ +#define CONFIG_CMD_CLEAR /* ANSI clear screen command */ #define CONFIG_CMD_CONSOLE /* coninfo */ #define CONFIG_CMD_DATE /* support for RTC, date/time...*/ #define CONFIG_CMD_DHCP /* DHCP Support */