1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Fixed delete when going off left side of screen

This commit is contained in:
James Booth 2012-07-09 23:48:53 +01:00
parent 32a5e07a9b
commit 11125561f8
3 changed files with 18 additions and 4 deletions

View File

@ -51,7 +51,6 @@
#include "command.h"
static WINDOW *inp_win;
static int MAX_INP_SIZE = 1000;
static int pad_start = 0;
static int _handle_edit(const int ch, char *input, int *size);
@ -63,7 +62,7 @@ void create_input_window(void)
int 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));
keypad(inp_win, TRUE);
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 (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);
@ -213,6 +215,16 @@ static int _handle_edit(const int ch, char *input, int *size)
waddch(inp_win, input[i]);
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;

View File

@ -41,7 +41,7 @@ void profanity_run(void)
inp_non_block();
while(cmd_result == TRUE) {
int ch = ERR;
char inp[200];
char inp[INP_WIN_MAX];
int size = 0;
while(ch != '\n') {

View File

@ -28,6 +28,8 @@
#include "common.h"
#include "contact_list.h"
#define INP_WIN_MAX 1000
struct prof_win {
char from[100];
WINDOW *win;