Thread (1 message) 1 message, 1 author, 2017-11-16

Re: [RFC] Indicate that Git waits for user input via editor

From: Junio C Hamano <hidden>
Date: 2017-11-16 05:37:30

Junio C Hamano [off-list ref] writes:
I wonder if we can do something like
...
to tentatively give a message without permanently wasting the
vertical space.
Learning from 13e4760a ("recv_sideband: Do not use ANSI escape
sequence on dumb terminals.", 2008-01-08), I think the above should
be more like this:

	git_spawn_editor()
	{
		static const char *finish;

		if (!finish) {
			const char ANSI_FINISH[] = "\r\033[K";
			const char DUMB_FINISH[] = "done.\n";
			char *term = getenv("TERM");

			if (term && strcmp(term, "dumb"))
				finish = ANSI_FINISH;
			else
				finish = DUMB_FINISH;
		}

		/* notice the lack of terminating LF */
		fprintf(stderr, "Launched your editor, waiting...");
		fflush(stderr);

		if (!run_command(... spawn the editor ...))
			fputs(finish, stderr);
		else
			fprintf(stderr, "failed (%s)\n", strerror(errno));
		fflush(stderr);
	}
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help