Get rid of center_x and center_y, removed redundant free_node, added restore of totsize when unjustifying

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@492 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
master
Chris Allegretta 2001-01-20 21:40:07 +00:00
parent 8d9b11a847
commit 17dcb7212f
5 changed files with 27 additions and 30 deletions

View File

@ -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

View File

@ -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 */

35
nano.c
View File

@ -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();
}

View File

@ -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;

10
winio.c
View File

@ -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);