From 9483f6a86f0001300b88e046beea0e38a98e9726 Mon Sep 17 00:00:00 2001 From: faissaloo Date: Fri, 26 Aug 2016 17:09:58 +0100 Subject: [PATCH 08/20] Code formatting --- src/revision.h | 2 +- src/winio.c | 93 ++++++++++++++++++++++++---------------------------------- 2 files changed, 40 insertions(+), 55 deletions(-) diff --git a/src/revision.h b/src/revision.h index 247816e..d7c5014 100644 --- a/src/revision.h +++ b/src/revision.h @@ -1 +1 @@ -#define REVISION "" +#define REVISION "v2.6.3-28-ga588f1a" diff --git a/src/winio.c b/src/winio.c index 4160c8d..43d3c61 100644 --- a/src/winio.c +++ b/src/winio.c @@ -2158,8 +2158,8 @@ void reset_cursor(void) int intlen(int n) { - if (n < 100000) - { + if (n < 100000) + { // 5 or less if (n < 100){ // 1 or 2 @@ -2172,20 +2172,14 @@ int intlen(int n) { // 3 or 4 or 5 if (n < 1000) - { - return 3; - } + return 3; else { // 4 or 5 if (n < 10000) - { - return 4; - } + return 4; else - { - return 5; - } + return 5; } } } @@ -2196,45 +2190,36 @@ int intlen(int n) { // 6 or 7 if (n < 1000000) - { return 6; - } else - { - return 7; - } + return 7; } else { // 8 to 10 if (n < 100000000) - { - return 8; - } + return 8; else { // 9 or 10 if (n < 1000000000) - { - return 9; - } + return 9; else - { - return 10; - } + return 10; } } } } + int hexlen(int n) { - int len=0; - while (n!=0) - { - n>>=4; //One hex digit = one nibble - len++; - } - return len; + int len=0; + while (n!=0) + { + n>>=4; //One hex digit = one nibble + len++; + } + return len; } /* edit_draw() takes care of the job of actually painting a line into * the edit window. fileptr is the line to be painted, at row line of @@ -2247,32 +2232,32 @@ int hexlen(int n) void edit_draw(filestruct *fileptr, const char *converted, int line, size_t start) { - #ifndef DISABLE_LINE_NUM - if (ISSET(LINE_NUM)) - { - if (margin!=intlen(openfile->filebot->lineno)+3) + #ifndef DISABLE_LINE_NUM + if (ISSET(LINE_NUM)) { - refresh_needed = TRUE; - margin = intlen(openfile->filebot->lineno)+3; + if (margin!=intlen(openfile->filebot->lineno)+3) + { + refresh_needed = TRUE; + margin = intlen(openfile->filebot->lineno)+3; + } + + wattron(edit,A_BOLD); + mvwprintw(edit,line,margin-(intlen(((long)openfile->edittop->lineno)+line)+2),"%i│",((long)openfile->edittop->lineno)+line); + wattroff(edit,A_BOLD); } - - wattron(edit,A_BOLD); - mvwprintw(edit,line,margin-(intlen(((long)openfile->edittop->lineno)+line)+2),"%i│",((long)openfile->edittop->lineno)+line); - wattroff(edit,A_BOLD); - } - else if (ISSET(HEX_LINE_NUM)) - { - if (margin!=hexlen(openfile->filebot->lineno)+3) + else if (ISSET(HEX_LINE_NUM)) { - refresh_needed = TRUE; - margin = hexlen(openfile->filebot->lineno)+3; + if (margin!=hexlen(openfile->filebot->lineno)+3) + { + refresh_needed = TRUE; + margin = hexlen(openfile->filebot->lineno)+3; + } + + wattron(edit,A_BOLD); + mvwprintw(edit,line,margin-(hexlen(((long)openfile->edittop->lineno)+line)+2),"%X│",((long)openfile->edittop->lineno)+line); + wattroff(edit,A_BOLD); } - - wattron(edit,A_BOLD); - mvwprintw(edit,line,margin-(hexlen(((long)openfile->edittop->lineno)+line)+2),"%X│",((long)openfile->edittop->lineno)+line); - wattroff(edit,A_BOLD); - } - #endif + #endif #if !defined(NANO_TINY) || !defined(DISABLE_COLOR) size_t startpos = actual_x(fileptr->data, start); /* The position in fileptr->data of the leftmost character -- 2.7.4