mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] edit: Add a status line
Date: Wed, 16 May 2012 08:51:23 +0200	[thread overview]
Message-ID: <1337151083-5576-1-git-send-email-s.hauer@pengutronix.de> (raw)

When invoked from a skript it's useful to know which file is edited. Also
Add information how to exit the editor to the status line.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 commands/edit.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/commands/edit.c b/commands/edit.c
index fae76cd..eddec0b 100644
--- a/commands/edit.c
+++ b/commands/edit.c
@@ -62,7 +62,7 @@ static int scrcol = 0;		/* the first column on screen */
 
 static void pos(int x, int y)
 {
-	printf("%c[%d;%dH", 27, y + 1, x + 1);
+	printf("%c[%d;%dH", 27, y + 2, x + 1);
 }
 
 static char *screenline(char *line, int *pos)
@@ -409,6 +409,17 @@ static int do_edit(int argc, char *argv[])
 	lastscrcol = 0;
 
 	printf("%c[2J", 27);
+
+	pos(0, -1);
+
+	printf("%c[7m %-25s <ctrl-d>: Save and quit <ctrl-c>: quit %c[0m",
+			27, argv[1], 27);
+	printf("%c[2;%dr", 27, screenheight);
+
+	screenheight--; /* status line */
+
+	pos(0, 0);
+
 	refresh(1);
 
 	while (1) {
@@ -416,7 +427,7 @@ static int do_edit(int argc, char *argv[])
 
 		if (textx > curlen)
 			textx = curlen;
-		if (textx < 0)
+		if (textx < 1)
 			textx = 0;
 
 		screenline(curline->data, &linepos);
@@ -531,7 +542,7 @@ static int do_edit(int argc, char *argv[])
 	}
 out:
 	free_buffer();
-	printf("%c[2J", 27);
+	printf("%c[2J%c[r", 27, 27);
 	printf("\n");
 	return 0;
 }
-- 
1.7.10


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2012-05-16  6:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1337151083-5576-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox