pwman

Check-in [1559d3c956]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Don't overwrite fields if only carriage return is entered

In other words, prevent accidentally deleting fields. This has always
bugged me about PWman. If I edit an entry and accidentally press a
number to edit one of the fields there is no way to escape out of this.
You have to re-type or paste in the old value.

This small change means that if you just enter return then the old value
is kept.

This is good enough for me. There is one downside: if you really want to
make a field blank the only way to do it is by entering a space and then
return - but I can't think of anytime I've ever wanted to do that.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | origin/tweaks | trunk
Files: files | file ages | folders
SHA3-256: 1559d3c95645eb1cb6ab8c55a25d559ea49a8c2a0fe5ecf56aa003ca10d59f8b
User & Date: atomicules@lavabit.com 2013-03-22 17:02:02
Context
2013-03-23
21:27
Extend the "don't overwrite fields if only carriage return is entered" to password field

And also use malloc. What I'd done before wasn't doing what I thought. C
newbie and all that. It must have picked up whatever `input` was
initialised at, which must be one of STRING_SHORT, STRING_MEDIUM, etc.
So it was just by luck it was working. It could have ended up truncating
strings I guess?

I'm in two minds about the benefit of dynamic allocation though. Since
this is hardly a big memory hungry application I could probably just
set `oldinput` to the largest possible string length and it'd be fine. check-in: 378769ec43 user: atomicules@lavabit.com tags: origin/tweaks, trunk

2013-03-22
17:02
Don't overwrite fields if only carriage return is entered

In other words, prevent accidentally deleting fields. This has always
bugged me about PWman. If I edit an entry and accidentally press a
number to edit one of the fields there is no way to escape out of this.
You have to re-type or paste in the old value.

This small change means that if you just enter return then the old value
is kept.

This is good enough for me. There is one downside: if you really want to
make a field blank the only way to do it is by entering a space and then
return - but I can't think of anytime I've ever wanted to do that. check-in: 1559d3c956 user: atomicules@lavabit.com tags: origin/tweaks, trunk

17:01
Merge branch 'modernise' into tweaks2 check-in: 9ed6b07353 user: atomicules@lavabit.com tags: origin/tweaks, trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/ui.c.

458
459
460
461
462
463
464

465



466
467
468
469
470
471
472
473
474
475
476
477
478
479





480
481
482
483
484
485
486

char *
ui_statusline_ask_str(char *msg, char *input, int len)
{
	char *tmp;
	char *tmp2;
	char *tmp3;

	int x = strlen(msg) + 5;




	if(input == NULL){
		input = malloc(len);
	}
	ui_statusline_clear();
	ui_statusline_msg(msg);

	echo();
	show_cursor();
	mvwgetnstr(bottom, 1, x, input, len);
	noecho();
	hide_cursor();

	ui_statusline_clear();






	// Tabs don't play nicely with ncurses or xml
	// So, swap any for (a single) space
	tmp = input;
	while(*tmp != 0) {
		if(*tmp == 9) *tmp = ' ';
		tmp++;







>

>
>
>














>
>
>
>
>







458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495

char *
ui_statusline_ask_str(char *msg, char *input, int len)
{
	char *tmp;
	char *tmp2;
	char *tmp3;
	char oldinput[strlen(input)];
	int x = strlen(msg) + 5;

	//Back-up the old value	
	strcpy(oldinput, input);

	if(input == NULL){
		input = malloc(len);
	}
	ui_statusline_clear();
	ui_statusline_msg(msg);

	echo();
	show_cursor();
	mvwgetnstr(bottom, 1, x, input, len);
	noecho();
	hide_cursor();

	ui_statusline_clear();

	//If just return entered, don't overwrite old value
	if(strlen(input) == 0){
		strcpy(input, oldinput);
	}

	// Tabs don't play nicely with ncurses or xml
	// So, swap any for (a single) space
	tmp = input;
	while(*tmp != 0) {
		if(*tmp == 9) *tmp = ' ';
		tmp++;