diff --git a/ChangeLog b/ChangeLog index 48e74b34049d32c1a2b71fbb5bab658a97bd58c5..eb23dd04c6bd6995e24f3c5c4460f34f0f4eb100 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,10 @@ CVS code - +General + - Removed current_x and current_y globals. current_y was + completely unused and current_x was only used a few places, + easily replaced with COLS / 2. + - Deleted free_node, duplicate of delete_node, and changed all + free_node calls to delete_node. - files.c: write_file() - Don't free() realname on error, if it needs to be free()d later @@ -6,6 +12,9 @@ CVS code - discovered by David Sobon). username_tab_completion() - Optimization and removal of useless vars (Rocco). +- nano.c: + do_justify() + - Added restoration of totsize after unjustify command. nano 0.9.99-pre1 - 01/17/2001 General diff --git a/global.c b/global.c index 31d877eac58702ec7c988ff287552366c15dfd8c..ba0a1c82afac653cdb037ff7b4976b1af75be7b6 100644 --- a/global.c +++ b/global.c @@ -35,7 +35,6 @@ * Global variables */ int flags = 0; /* Our new flag containig many options */ -int center_x = 0, center_y = 0; /* Center of screen */ WINDOW *edit; /* The file portion of the editor */ WINDOW *topwin; /* Top line of screen */ WINDOW *bottomwin; /* Bottom buffer */ diff --git a/nano.c b/nano.c index 2517ba25385fbdafb93bf5b405e5b18247d70b73..dd3444312b37ed98ff8d1eda8e463b6e7bafc202 100644 --- a/nano.c +++ b/nano.c @@ -169,8 +169,6 @@ void global_init(void) { int i; - center_x = COLS / 2; - center_y = LINES / 2; current_x = 0; current_y = 0; @@ -254,8 +252,11 @@ void unlink_node(filestruct * fileptr) void delete_node(filestruct * fileptr) { + if (fileptr == NULL) + return; + if (fileptr->data != NULL) - free(fileptr->data); + free(fileptr->data); free(fileptr); } @@ -283,18 +284,6 @@ filestruct *copy_filestruct(filestruct * src) return head; } -/* Free() a single node */ -int free_node(filestruct * src) -{ - if (src == NULL) - return 0; - - if (src->next != NULL) - free(src->data); - free(src); - return 1; -} - int free_filestruct(filestruct * src) { filestruct *fileptr = src; @@ -304,15 +293,15 @@ int free_filestruct(filestruct * src) while (fileptr->next != NULL) { fileptr = fileptr->next; - free_node(fileptr->prev); + delete_node(fileptr->prev); #ifdef DEBUG - fprintf(stderr, _("free_node(): free'd a node, YAY!\n")); + fprintf(stderr, _("delete_node(): free'd a node, YAY!\n")); #endif } - free_node(fileptr); + delete_node(fileptr); #ifdef DEBUG - fprintf(stderr, _("free_node(): free'd last node.\n")); + fprintf(stderr, _("delete_node(): free'd last node.\n")); #endif return 1; @@ -1571,9 +1560,6 @@ void handle_sigwinch(int s) COLS = win.ws_col; LINES = win.ws_row; - center_x = COLS / 2; - center_y = LINES / 2; - if ((editwinrows = LINES - 5 + no_help()) < MIN_EDITOR_ROWS) die_too_small(); @@ -1751,7 +1737,7 @@ int do_justify(void) return 1; #else int slen = 0; /* length of combined lines on one line. */ - int initial_y, kbinput = 0; + int initial_y, kbinput = 0, totbak; filestruct *initial = NULL, *tmpjust = NULL, *cutbak, *tmptop, *tmpbot; if (empty_line(current->data)) { @@ -1791,6 +1777,7 @@ int do_justify(void) set_modified(); cutbak = cutbuffer; /* Got to like cutbak ;) */ + totbak = totsize; cutbuffer = NULL; tmptop = current; @@ -1915,6 +1902,8 @@ int do_justify(void) if (tmptop->prev == NULL) edit_refresh(); + /* Restore totsize from befure justify */ + totsize = totbak; free_filestruct(tmptop); blank_statusbar_refresh(); } diff --git a/proto.h b/proto.h index 275fba713876eb9187d0fe335e0545592d4fedd8..3e7a005e68d3b4e86240f7230d662b7f1b606144 100644 --- a/proto.h +++ b/proto.h @@ -29,7 +29,7 @@ #include "nano.h" -extern int center_x, center_y, editwinrows; +extern int editwinrows; extern int current_x, current_y, posible_max, totlines; extern int placewewant; extern int mark_beginx, samelinewrap; diff --git a/winio.c b/winio.c index 951bf1bf9bac4348c02cccb35ca19046b64454ee..06e6530883b11b0d22632ddc5f972e1df4cde0c6 100644 --- a/winio.c +++ b/winio.c @@ -480,7 +480,7 @@ void titlebar(char *path) namelen = strlen(what); if (!strcmp(what, "")) - mvwaddstr(topwin, 0, center_x - 6, _("New Buffer")); + mvwaddstr(topwin, 0, COLS / 2 - 6, _("New Buffer")); else { if (namelen > space) { if (path == NULL) @@ -490,9 +490,9 @@ void titlebar(char *path) waddstr(topwin, &what[namelen - space]); } else { if (path == NULL) - mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), "File: "); + mvwaddstr(topwin, 0, COLS / 2 - (namelen / 2 + 1), "File: "); else - mvwaddstr(topwin, 0, center_x - (namelen / 2 + 1), " DIR: "); + mvwaddstr(topwin, 0, COLS / 2 - (namelen / 2 + 1), " DIR: "); waddstr(topwin, what); } } @@ -1090,7 +1090,7 @@ void statusbar(char *msg, ...) vsnprintf(foo, 132, msg, ap); va_end(ap); - start_x = center_x - strlen(foo) / 2 - 1; + start_x = COLS / 2 - strlen(foo) / 2 - 1; /* Blank out line */ blank_statusbar(); @@ -1447,7 +1447,7 @@ void do_credits(void) else what = ""; - start_x = center_x - strlen(what) / 2 - 1; + start_x = COLS / 2 - strlen(what) / 2 - 1; mvwaddstr(edit, i * 2 - k, start_x, what); } usleep(700000);