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
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
* 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 */
{
int i;
- center_x = COLS / 2;
- center_y = LINES / 2;
current_x = 0;
current_y = 0;
void delete_node(filestruct * fileptr)
{
+ if (fileptr == NULL)
+ return;
+
if (fileptr->data != NULL)
- free(fileptr->data);
+ free(fileptr->data);
free(fileptr);
}
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;
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;
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();
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)) {
set_modified();
cutbak = cutbuffer; /* Got to like cutbak ;) */
+ totbak = totsize;
cutbuffer = NULL;
tmptop = current;
if (tmptop->prev == NULL)
edit_refresh();
+ /* Restore totsize from befure justify */
+ totsize = totbak;
free_filestruct(tmptop);
blank_statusbar_refresh();
}
#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;
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)
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);
}
}
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();
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);