summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Grenier <[email protected]>2009-04-18 18:13:15 +0200
committerChristophe Grenier <[email protected]>2009-04-18 18:13:15 +0200
commitb9fbd6cadb4f610ccdff30ffc59e87b354cc90d1 (patch)
tree0a5aa9537c2c988d36c719db6fd61e877d11d6ee
parent77d476a5ca79f234b5d9840fe83be9637ce94f53 (diff)
Handle more than 80 columns
-rw-r--r--src/edit.c10
-rw-r--r--src/geometry.c12
-rw-r--r--src/intrf.c14
-rw-r--r--src/intrf.h5
-rw-r--r--src/intrfn.c21
-rw-r--r--src/intrfn.h1
6 files changed, 30 insertions, 33 deletions
diff --git a/src/edit.c b/src/edit.c
index f5b9d1a5..46399574 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -128,8 +128,8 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
{
CHS_t position;
int done = 0;
- char def[LINE_LENGTH];
- char response[LINE_LENGTH];
+ char def[128];
+ char response[128];
unsigned long int tmp_val;
int command;
position.cylinder=offset2cylinder(disk_car,*lba);
@@ -153,7 +153,7 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
case 'C':
sprintf(def, "%lu", position.cylinder);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atol(response);
if (tmp_val < disk_car->geom.cylinders) {
position.cylinder = tmp_val;
@@ -165,7 +165,7 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
case 'H':
sprintf(def, "%u", position.head);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of heads: ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atoi(response);
if (tmp_val < disk_car->geom.heads_per_cylinder) {
position.head = tmp_val;
@@ -177,7 +177,7 @@ static void interface_editor_position(const disk_t *disk_car,uint64_t *lba)
case 'S':
sprintf(def, "%u", position.sector);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of sectors per track: ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atoi(response);
if (tmp_val > 0 && tmp_val <= disk_car->geom.sectors_per_head ) {
position.sector = tmp_val;
diff --git a/src/geometry.c b/src/geometry.c
index 03570703..4193c78f 100644
--- a/src/geometry.c
+++ b/src/geometry.c
@@ -144,8 +144,8 @@ static void change_geometry_cli(disk_t *disk_car, char ** current_cmd)
static void change_geometry_ncurses(disk_t *disk_car)
{
int done = 0;
- char def[LINE_LENGTH];
- char response[LINE_LENGTH];
+ char def[128];
+ char response[128];
long int tmp_val=0;
int command;
int default_option=4;
@@ -187,7 +187,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
{
sprintf(def, "%lu", disk_car->geom.cylinders);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of cylinders: ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atol(response);
if (tmp_val > 0) {
disk_car->geom.cylinders = tmp_val;
@@ -204,7 +204,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
{
sprintf(def, "%u", disk_car->geom.heads_per_cylinder);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of heads: ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atoi(response);
if (tmp_val > 0 && tmp_val <= MAX_HEADS) {
disk_car->geom.heads_per_cylinder = tmp_val;
@@ -223,7 +223,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
sprintf(def, "%u", disk_car->geom.sectors_per_head);
/* FIXME SUN partition can have more than 63 sectors */
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the number of sectors per track (1-63): ");
- if (get_string(response, LINE_LENGTH, def) > 0)
+ if (get_string(response, sizeof(response), def) > 0)
{
tmp_val = atoi(response);
/* TODO Check for the maximum value */
@@ -243,7 +243,7 @@ static void change_geometry_ncurses(disk_t *disk_car)
{
sprintf(def, "%u", disk_car->sector_size);
mvwaddstr(stdscr,INTER_GEOM_Y, INTER_GEOM_X, "Enter the sector size (512, 1024, 2048, 4096): ");
- if (get_string(response, LINE_LENGTH, def) > 0) {
+ if (get_string(response, sizeof(response), def) > 0) {
tmp_val = atoi(response);
/* FIXME using 3*512=1536 as sector size and */
/* 63/3=21 for number of sectors is an easy way to test */
diff --git a/src/intrf.c b/src/intrf.c
index 0974fdb2..a7ac5d46 100644
--- a/src/intrf.c
+++ b/src/intrf.c
@@ -63,7 +63,7 @@
#include "dir.h"
#include "log.h"
-char intr_buffer_screen[MAX_LINES][LINE_LENGTH+1];
+char intr_buffer_screen[MAX_LINES][BUFFER_LINE_LENGTH+1];
int intr_nbr_line=0;
int screen_buffer_add(const char *_format, ...)
@@ -71,14 +71,14 @@ int screen_buffer_add(const char *_format, ...)
char tmp_line[BUFFER_LINE_LENGTH+1];
char *pos_in_tmp_line=tmp_line;
va_list ap;
+ memset(tmp_line, '\0', sizeof(tmp_line));
va_start(ap,_format);
- memset(tmp_line,'\0',sizeof(tmp_line));
- vsnprintf(tmp_line,BUFFER_LINE_LENGTH,_format,ap);
+ vsnprintf(tmp_line, sizeof(tmp_line), _format, ap);
va_end(ap);
while(pos_in_tmp_line!=NULL && (intr_nbr_line<MAX_LINES))
{
- unsigned int len=strlen(intr_buffer_screen[intr_nbr_line]);
- unsigned int nbr=LINE_LENGTH-len;
+ const unsigned int len=strlen(intr_buffer_screen[intr_nbr_line]);
+ unsigned int nbr=BUFFER_LINE_LENGTH-len;
char *ret_ligne= strchr(pos_in_tmp_line,'\n');
if(ret_ligne!=NULL && ret_ligne-pos_in_tmp_line < nbr)
nbr=ret_ligne-pos_in_tmp_line;
@@ -116,10 +116,8 @@ void screen_buffer_to_stdout()
void screen_buffer_reset()
{
- int i;
intr_nbr_line=0;
- for(i=0;i<MAX_LINES;i++)
- memset(intr_buffer_screen[i],0,LINE_LENGTH+1);
+ memset(intr_buffer_screen, 0, sizeof(intr_buffer_screen));
}
void screen_buffer_to_log()
diff --git a/src/intrf.h b/src/intrf.h
index c55d9e22..9bdd06f9 100644
--- a/src/intrf.h
+++ b/src/intrf.h
@@ -30,11 +30,9 @@ struct MenuItem
const char *desc; /* Item description to be printed when item is selected */
};
#define MAX_LINES 200
-#define LINE_LENGTH 80
-#define BUFFER_LINE_LENGTH 4*LINE_LENGTH
+#define BUFFER_LINE_LENGTH 255
#define MAXIMUM_PARTS 60
#define WARNING_START 23
-#define COLUMNS 80
#define INTER_OPTION_X 0
#define INTER_OPTION_Y 10
@@ -70,7 +68,6 @@ int ask_confirmation(const char*_format, ...) __attribute__ ((format (printf, 1,
unsigned long long int ask_number(const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 4, 5)));
unsigned long long int ask_number_cli(char **current_cmd, const unsigned long long int val_cur, const unsigned long long int val_min, const unsigned long long int val_max, const char * _format, ...) __attribute__ ((format (printf, 5, 6)));
int display_message_aux(const char*_format,...) __attribute__ ((format (printf, 1, 2)));
-int get_string(char *str, int len, char *def);
void not_implemented(const char *msg);
void screen_buffer_reset(void);
int screen_buffer_add(const char *_format, ...) __attribute__ ((format (printf, 1, 2)));
diff --git a/src/intrfn.c b/src/intrfn.c
index 47e1c62e..d42ad846 100644
--- a/src/intrfn.c
+++ b/src/intrfn.c
@@ -70,9 +70,10 @@ extern const arch_fnct_t arch_mac;
extern const arch_fnct_t arch_none;
extern const arch_fnct_t arch_sun;
extern const arch_fnct_t arch_xbox;
-extern char intr_buffer_screen[MAX_LINES][LINE_LENGTH+1];
+extern char intr_buffer_screen[MAX_LINES][BUFFER_LINE_LENGTH+1];
extern int intr_nbr_line;
+#define COLUMNS 80
/* Use COLS (actual number of columns) or COLUMNS (number of columns the program has been designed for) ? */
#define INTER_DIR (LINES+16-25)
#define GS_DEFAULT -1
@@ -81,7 +82,7 @@ extern int intr_nbr_line;
static int wmenuUpdate(WINDOW *window, const int yinfo, int y, int x, const struct MenuItem *menuItems, const unsigned int itemLength, const char *available, const int menuType, unsigned int current);
static int wgetch_nodelay(WINDOW *window);
-int get_string(char *str, int len, char *def)
+int get_string(char *str, const int len, const char *def)
{
int c;
int i = 0;
@@ -442,8 +443,8 @@ unsigned long long int ask_number(const unsigned long long int val_cur, const un
{
char res[200];
char res2[200];
- char response[LINE_LENGTH];
- char def[LINE_LENGTH];
+ char response[128];
+ char def[128];
unsigned long int tmp_val;
va_list ap;
va_start(ap,_format);
@@ -456,7 +457,7 @@ unsigned long long int ask_number(const unsigned long long int val_cur, const un
waddstr(stdscr, res);
waddstr(stdscr, res2);
sprintf(def, "%llu", val_cur);
- if (get_string(response, LINE_LENGTH, def) > 0)
+ if (get_string(response, sizeof(response), def) > 0)
{
#ifdef HAVE_ATOLL
tmp_val = atoll(response);
@@ -797,7 +798,7 @@ int screen_buffer_display_ext(WINDOW *window, const char *options_org, const str
wclrtoeol(window);
if(i==current_line)
wattrset(window, A_REVERSE);
- wprintw(window,"%s",intr_buffer_screen[i]);
+ wprintw(window, "%-*s", COLS, intr_buffer_screen[i]);
if(i==current_line)
wattroff(window, A_REVERSE);
}
@@ -808,7 +809,7 @@ int screen_buffer_display_ext(WINDOW *window, const char *options_org, const str
{
wmove(window,INTER_ANALYSE_Y+i-first_line_to_display,INTER_ANALYSE_X);
wclrtoeol(window);
- wprintw(window,"%s",intr_buffer_screen[i]);
+ wprintw(window, "%-*s", COLS, intr_buffer_screen[i]);
}
}
wmove(window, INTER_ANALYSE_Y+INTER_MAX_LINES, INTER_ANALYSE_X+4);
@@ -1112,7 +1113,7 @@ int end_ncurses()
char *ask_log_location(const char*filename)
{
- static char response[LINE_LENGTH];
+ static char response[128];
aff_copy(stdscr);
if(filename!=NULL)
{
@@ -1128,7 +1129,7 @@ char *ask_log_location(const char*filename)
wbkgdset(stdscr,' ' | COLOR_PAIR(0));
wmove(stdscr,9,0);
wprintw(stdscr,"to abort log file creation.\n");
- if (get_string(response, LINE_LENGTH, NULL) > 0)
+ if (get_string(response, sizeof(response), NULL) > 0)
return response;
return NULL;
}
@@ -1233,7 +1234,7 @@ void screen_buffer_to_interface()
{
wmove(stdscr,DUMP_Y+1+i-pos,DUMP_X);
wclrtoeol(stdscr);
- wprintw(stdscr,"%s",intr_buffer_screen[i]);
+ wprintw(stdscr, "%-*s", COLS, intr_buffer_screen[i]);
}
wrefresh(stdscr);
}
diff --git a/src/intrfn.h b/src/intrfn.h
index 603d5b18..6bdc374b 100644
--- a/src/intrfn.h
+++ b/src/intrfn.h
@@ -53,6 +53,7 @@ int end_ncurses(void);
int interface_partition_type_ncurses(disk_t *disk_car);
int vaff_txt(int line, WINDOW *window, const char *_format, va_list ap) __attribute__((format(printf, 3, 0)));
char *ask_log_location(const char*filename);
+int get_string(char *str, const int len, const char *def);
#endif
void display_message(const char*msg);