From patchwork Tue Jan 24 14:28:04 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: 137572 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 26C57B6F62 for ; Wed, 25 Jan 2012 01:32:34 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 04BA728177; Tue, 24 Jan 2012 15:31:44 +0100 (CET) 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 QfngN-3zHFZ7; Tue, 24 Jan 2012 15:31:43 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A5DBC28109; Tue, 24 Jan 2012 15:31:33 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id BAF7F28177 for ; Tue, 24 Jan 2012 15:31:26 +0100 (CET) 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 Coy+uee+CI8e for ; Tue, 24 Jan 2012 15:31:25 +0100 (CET) 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-ww0-f52.google.com (mail-ww0-f52.google.com [74.125.82.52]) by theia.denx.de (Postfix) with ESMTPS id B78BE280A2 for ; Tue, 24 Jan 2012 15:31:20 +0100 (CET) Received: by wgbdq12 with SMTP id dq12so4826439wgb.9 for ; Tue, 24 Jan 2012 06:31:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=WflSiNbF383NY2QVK/G44TLWeJ2PUuKinrxSL4FfwGU=; b=Pk6gp/8w35fO/rr/mPEdoJDmOBjQqZFdXGGyJRHFjPpjAQQN3+89iByW94qtItnzzx XmjUkyVT+6p5A48Q3fxm2JmqHQxDC4ShYsTDpQv0TEp+sNCAHctgHTow+Cjh1mO2qda8 tp7tzyJGlkwgoNIujB6p4ZjOIblgNvTqrpxBI= Received: by 10.180.8.103 with SMTP id q7mr21217862wia.1.1327415340435; Tue, 24 Jan 2012 06:29:00 -0800 (PST) Received: from Pali-EliteBook.kolej.mff.cuni.cz (pali.kolej.mff.cuni.cz. [78.128.193.202]) by mx.google.com with ESMTPS id n3sm52913728wiz.9.2012.01.24.06.28.58 (version=SSLv3 cipher=OTHER); Tue, 24 Jan 2012 06:28:59 -0800 (PST) From: =?UTF-8?q?Pali=20Roh=C3=A1r?= To: u-boot@lists.denx.de Date: Tue, 24 Jan 2012 15:28:04 +0100 Message-Id: <1327415291-13260-8-git-send-email-pali.rohar@gmail.com> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1327415291-13260-1-git-send-email-pali.rohar@gmail.com> References: <1327415291-13260-1-git-send-email-pali.rohar@gmail.com> MIME-Version: 1.0 Cc: =?UTF-8?q?Pali=20Roh=C3=A1r?= Subject: [U-Boot] [PATCH 07/14] cfb_console: Add functions for moving with cursor 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 * console_cursor_fix - fix cursor position (check for out of screen) * console_cursor_up, console_cursor_down, console_cursor_left, console_cursor_right, console_cursor_set_position for change cursor position * console_newline - added param to specify count of creating new lines * console_previewsline - opposite of console_newline Signed-off-by: Pali Rohár --- Changes since original version: - Fixed commit message drivers/video/cfb_console.c | 64 +++++++++++++++++++++++++++++++++++++++---- 1 files changed, 58 insertions(+), 6 deletions(-) diff --git a/drivers/video/cfb_console.c b/drivers/video/cfb_console.c index b74d6d0..3823eae 100644 --- a/drivers/video/cfb_console.c +++ b/drivers/video/cfb_console.c @@ -773,9 +773,54 @@ static void console_back(void) CURSOR_SET; } -static void console_newline(void) +static void console_cursor_fix(void) { - console_row++; + if (console_row < 0) + console_row = 0; + if (console_row >= CONSOLE_ROWS) + console_row = CONSOLE_ROWS-1; + if (console_col < 0) + console_col = 0; + if (console_col >= CONSOLE_COLS) + console_col = CONSOLE_COLS-1; +} + +static void console_cursor_up(int n) +{ + console_row -= n; + console_cursor_fix(); +} + +static void console_cursor_down(int n) +{ + console_row += n; + console_cursor_fix(); +} + +static void console_cursor_left(int n) +{ + console_col -= n; + console_cursor_fix(); +} + +static void console_cursor_right(int n) +{ + console_col += n; + console_cursor_fix(); +} + +static void console_cursor_set_position(int row, int col) +{ + if (console_row != -1) + console_row = row; + if (console_col != -1) + console_col = col; + console_cursor_fix(); +} + +static void console_newline(int n) +{ + console_row += n; console_col = 0; /* Check if we need to scroll the terminal */ @@ -784,10 +829,17 @@ static void console_newline(void) console_scrollup(); /* Decrement row number */ - console_row--; + console_row = CONSOLE_ROWS-1; } } +static void console_previewsline(int n) +{ + /* FIXME: also scroll terminal ? */ + console_row -= n; + console_cursor_fix(); +} + static void console_cr(void) { console_col = 0; @@ -806,7 +858,7 @@ void video_putc(const char c) case '\n': /* next line */ if (console_col || (!console_col && nl)) - console_newline(); + console_newline(1); nl = 1; break; @@ -815,7 +867,7 @@ void video_putc(const char c) console_col &= ~0x0007; if (console_col >= CONSOLE_COLS) - console_newline(); + console_newline(1); break; case 8: /* backspace */ @@ -829,7 +881,7 @@ void video_putc(const char c) /* check for newline */ if (console_col >= CONSOLE_COLS) { - console_newline(); + console_newline(1); nl = 0; } }