Skip to content

Commit

Permalink
Added more flexibility when resizing the terminal.
Browse files Browse the repository at this point in the history
Should work fine with the standard 80x24.
  • Loading branch information
allinurl committed Dec 9, 2010
1 parent 3d6562b commit 433e049
Show file tree
Hide file tree
Showing 7 changed files with 158 additions and 88 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Changes to GoAccess 0.4.1 - Monday, December 13, 2010

* Ability to pass a flag to ./configure so it can disable GeoIP
* More flexibility when resizing the terminal. Should work fine with
the standard 80x24.
* Implemented a pipeline from stdin, so the input is not necessarily
only a filename.

Changes to GoAccess 0.4 - Tuesday, November 30, 2010

* Rewrote hash tables iterative code to avoid the use of GHashTableIter,
Expand Down
6 changes: 3 additions & 3 deletions commons.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#define DATELEN 12
#define DEBUG
#define GO_UNUSED __attribute__((unused))
#define GO_VERSION "0.4"
#define GO_VERSION "0.4.1"
#define MAX_CHOICES 300
#define MIN_HEIGHT 40
#define MIN_WIDTH 97
#define MIN_HEIGHT 7
#define MIN_WIDTH 0
#define TOTAL_MODULES 11
/* max height of footer stdscr (rows) */
#define MAX_HEIGHT_FOOTER 1
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ(2.61)
AC_INIT([goaccess], [0.4], [[email protected]])
AC_INIT([goaccess], [0.4.1], [[email protected]])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([goaccess.c])
AC_CONFIG_HEADERS([config.h])
Expand Down
32 changes: 19 additions & 13 deletions goaccess.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ allocate_structs (int free_me)
/* allocate 10 per module */
MALLOC_STRUCT (s_display, 170);

/* note that the order in which we call them, is the way modules will be displayed */
/* note that the order in which we call them,
* is the way modules will be displayed */
generate_unique_visitors (s_display, logger);

MALLOC_STRUCT (s_holder, g_hash_table_size (ht_requests));
Expand Down Expand Up @@ -204,8 +205,8 @@ render_screens (void)
wattron (stdscr, COLOR_PAIR (COL_WHITE));
generate_time ();
chg = logger->total_process - initial_reqs;
mvaddstr (row - 1, 1, "[F1]Help [O]pen detail view");
mvprintw (row - 1, 32, "Updated: %d - %s", chg, asctime (now_tm));
mvaddstr (row - 1, 1, "[F1]Help [O]pen detail view");
mvprintw (row - 1, 30, "%d - %s", chg, asctime (now_tm));
mvaddstr (row - 1, col - 21, "[Q]uit Analyzer");

mvprintw (row - 1, col - 5, "%s", GO_VERSION);
Expand All @@ -221,7 +222,7 @@ render_screens (void)
/* display active label based on current module */
wattron (header_win, COLOR_PAIR (BLUE_GREEN));
wmove (header_win, 0, 30);
mvwprintw (header_win, 0, col - 20, "[Active Module %d]",
mvwprintw (header_win, 0, col - 19, "[Active Module %d]",
logger->current_module);
wattroff (header_win, COLOR_PAIR (BLUE_GREEN));
wrefresh (header_win);
Expand All @@ -236,14 +237,14 @@ static void
get_keys (void)
{
int y, x, c;
getmaxyx (main_win, y, x);

char buf[BUFFER];
FILE *fp;
unsigned long long size1, size2;

size1 = file_size (ifile);
while (((c = wgetch (stdscr)) != 'q')) {
getmaxyx (main_win, y, x);
switch (c) {
/* scroll down main_win */
case KEY_DOWN:
Expand Down Expand Up @@ -275,6 +276,8 @@ get_keys (void)
case KEY_RIGHT:
case 'o':
case 'O':
if ((x < 75) || (y < 12))
break; /* stdscr too small to create subwin */
my_menu_win = create_win (main_win);
load_popup (my_menu_win, s_holder, logger);
touchwin (main_win);
Expand Down Expand Up @@ -338,21 +341,25 @@ get_keys (void)
break;
case 8:
case 265:
help_win = newwin (y - 12, x - 40, 8, 20);
if ((x < 65) || (y < 12))
break; /* stdscr too small to create win */
help_win = newwin (y - 3, 57, 5, ((x - 57) / 2));
if (help_win == NULL)
error_handler (__PRETTY_FUNCTION__, __FILE__, __LINE__,
"Unable to allocate memory for new window.");
load_help_popup (help_win);
load_help_popup (help_win, ((x - 57) / 2));
wrefresh (help_win);
touchwin (main_win);
close_win (help_win);
break;
case 99:
schemes_win = newwin (10, 40, 8, 20);
if ((x < 75) || (y < 12))
break; /* stdscr too small to create win */
schemes_win = newwin (7, 57, 8, ((x - 57) / 2));
if (schemes_win == NULL)
error_handler (__PRETTY_FUNCTION__, __FILE__, __LINE__,
"Unable to allocate memory for new window.");
load_schemes_win (schemes_win);
load_schemes_win (schemes_win, ((x - 57) / 2));
wrefresh (schemes_win);
touchwin (main_win);
close_win (schemes_win);
Expand All @@ -374,9 +381,8 @@ get_keys (void)
/* file has changed */
if (size2 != size1) {
if (!(fp = fopen (ifile, "r")))
error_handler (__PRETTY_FUNCTION__,
__FILE__, __LINE__,
"Unable to read log file.");
error_handler (__PRETTY_FUNCTION__, __FILE__,
__LINE__, "Unable to read log file.");
if (!fseeko (fp, size1, SEEK_SET))
while (fgets (buf, BUFFER, fp) != NULL)
parse_log (logger, ifile, buf);
Expand Down Expand Up @@ -511,7 +517,7 @@ main (int argc, char *argv[])
getmaxyx (stdscr, row, col);
if (row < MIN_HEIGHT || col < MIN_WIDTH)
error_handler (__PRETTY_FUNCTION__, __FILE__, __LINE__,
"Minimum screen size - 97 columns by 40 lines");
"Minimum screen size - 0 columns by 7 lines");

header_win = newwin (5, col, 0, 0);
keypad (header_win, TRUE);
Expand Down
2 changes: 1 addition & 1 deletion parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ generate_unique_visitors (struct struct_display **s_display,
else if (i == 1)
s_display[logger->alloc_counter++]->data =
alloc_string
(" HTTP requests having the same IP, same date and same agent will be considered a unique visit");
(" HTTP requests having the same IP, same date and same agent are considered a unique visit");
else if (i == 2 || i == 9)
s_display[logger->alloc_counter++]->data = alloc_string ("");
else if (r < s_size) {
Expand Down
Loading

0 comments on commit 433e049

Please sign in to comment.