Fixed delete when going off left side of screen
This commit is contained in:
@@ -51,7 +51,6 @@
|
|||||||
#include "command.h"
|
#include "command.h"
|
||||||
|
|
||||||
static WINDOW *inp_win;
|
static WINDOW *inp_win;
|
||||||
static int MAX_INP_SIZE = 1000;
|
|
||||||
static int pad_start = 0;
|
static int pad_start = 0;
|
||||||
|
|
||||||
static int _handle_edit(const int ch, char *input, int *size);
|
static int _handle_edit(const int ch, char *input, int *size);
|
||||||
@@ -63,7 +62,7 @@ void create_input_window(void)
|
|||||||
int rows, cols;
|
int rows, cols;
|
||||||
getmaxyx(stdscr, rows, cols);
|
getmaxyx(stdscr, rows, cols);
|
||||||
|
|
||||||
inp_win = newpad(1, MAX_INP_SIZE);
|
inp_win = newpad(1, INP_WIN_MAX);
|
||||||
wbkgd(inp_win, COLOR_PAIR(1));
|
wbkgd(inp_win, COLOR_PAIR(1));
|
||||||
keypad(inp_win, TRUE);
|
keypad(inp_win, TRUE);
|
||||||
wmove(inp_win, 0, 0);
|
wmove(inp_win, 0, 0);
|
||||||
@@ -78,7 +77,10 @@ void inp_win_resize(const char * const input, const int size)
|
|||||||
|
|
||||||
// if lost cursor off screen, move contents to show it
|
// if lost cursor off screen, move contents to show it
|
||||||
if (inp_x >= pad_start + cols) {
|
if (inp_x >= pad_start + cols) {
|
||||||
pad_start = inp_x - 10;
|
pad_start = inp_x - (cols / 2);
|
||||||
|
if (pad_start < 0) {
|
||||||
|
pad_start = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
prefresh(inp_win, pad_start, 0, rows-1, 0, rows-1, cols-1);
|
prefresh(inp_win, pad_start, 0, rows-1, 0, rows-1, cols-1);
|
||||||
@@ -213,6 +215,16 @@ static int _handle_edit(const int ch, char *input, int *size)
|
|||||||
waddch(inp_win, input[i]);
|
waddch(inp_win, input[i]);
|
||||||
wmove(inp_win, 0, inp_x -1);
|
wmove(inp_win, 0, inp_x -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if gone off screen to left, jump left (half a screen worth)
|
||||||
|
if (inp_x <= pad_start) {
|
||||||
|
pad_start = pad_start - (cols / 2);
|
||||||
|
if (pad_start < 0) {
|
||||||
|
pad_start = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
prefresh(inp_win, 0, pad_start, rows-1, 0, rows-1, cols-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ void profanity_run(void)
|
|||||||
inp_non_block();
|
inp_non_block();
|
||||||
while(cmd_result == TRUE) {
|
while(cmd_result == TRUE) {
|
||||||
int ch = ERR;
|
int ch = ERR;
|
||||||
char inp[200];
|
char inp[INP_WIN_MAX];
|
||||||
int size = 0;
|
int size = 0;
|
||||||
|
|
||||||
while(ch != '\n') {
|
while(ch != '\n') {
|
||||||
|
|||||||
Reference in New Issue
Block a user