Commits

Anonymous committed 4f44bbf

move cursor wcwidth() of utf8 character on backspace

Comments (0)

Files changed (1)

 	int cols, left_prompt_len, right_prompt_len = 0;
 	struct winsize ws;
 
+	/*
 	if (ioctl(STDOUT, TIOCGWINSZ, &ws) < 0)
 		err(1, "failed ioctl");
 
 	if (start + cols < len)
 		my_write(STDOUT, scrl_prompt_right, right_prompt_len);
 
+		*/
+
+	erase_usr();
+	left_prompt_len = strlen(nrml_prompt);
+	my_write(STDOUT, nrml_prompt, left_prompt_len);
+	my_write(STDOUT, usrbuf, len);
 	cursor_beg();
 	cursor_fwd(left_prompt_len + wcur - start);
 	fflush(stdout);
 							;
 						if (cur != len)
 							shift_buf(usrbuf, cur, len, cur - i);
+						if (mbtowc(&wc, usrbuf + i, cur - i) < 0)
+							warnx("failed mbtowc conversion");
 						len = MAX(0, len - (cur - i));
 						cur = MAX(0, i);
-						wlen = MAX(0, wlen - 1);
-						wcur = MAX(0, wcur - 1);
+						if ((i = wcwidth(wc)) < 0)
+							warnx("failed wcwidth");
+						wlen = MAX(0, wlen - i);
+						wcur = MAX(0, wcur - i);
 						break;
 					case CTRL('a') : cur = wcur = 0;          break;
 					case CTRL('e') : cur = len; wcur = wlen;  break;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.