Permalink
Browse files

Change Anzahl name to COLUMNS_DATA and COLUMNS_HEX names

  • Loading branch information...
1 parent 28c87ad commit 430811d438a9f9f41858811546536c7d0b468ba2 @XVilka committed Aug 17, 2011
Showing with 149 additions and 75 deletions.
  1. +10 −0 TODO
  2. +20 −0 bscript.c
  3. +52 −29 bvi.c
  4. +2 −1 bvi.h
  5. +58 −38 edit.c
  6. +1 −1 re.c
  7. +6 −6 set.c
View
@@ -9,3 +9,13 @@
- Add support for 8-bit, 16-bit, 32-bit, 64-bit and 128-bit modes
- Add support for big-endian and little-endian
+Refactoring Tasks
+============================
+
+1. Split out math and logic functions in math.c (and/xor/etc)
+2. Implement Core and Editor objects/structures
+3. Convert editor output to editor container (for support splitting/diff features)
+4. Eliminate DOS stuff
+5. Add file stream object for supporting continious and large files
+6. Split all output to another file console.c, add unified API for GUI
+
View
@@ -78,6 +78,25 @@ static int bvi_block_select(lua_State *L)
return 0;
}
+/* Fold block in the buffer */
+/* lua: block_fold(block_number) */
+static int bvi_block_fold(lua_State *L)
+{
+ unsigned int n = 0;
+ if (lua_gettop(L) == 1) {
+ n = (unsigned int)lua_tonumber(L, 1);
+ if ((n < BLK_COUNT) & ((data_block[n].pos_end - data_block[n].pos_start) > 0)) {
+ data_block[n].folding = 1;
+ repaint();
+ } else {
+ emsg("Wrong block number!");
+ }
+ } else {
+ msg("Error in lua block_fold function! Wrong format!");
+ }
+ return 0;
+}
+
/* Read block in the buffer */
/* lua: block_read(block_number) */
static int bvi_block_read(lua_State *L)
@@ -774,6 +793,7 @@ void bvi_lua_init()
{"file", bvi_file},
{"exec", bvi_exec},
{"block_select", bvi_block_select},
+ {"block_fold", bvi_block_fold},
{"block_read", bvi_block_read},
{"block_and", bvi_block_and},
{"block_or", bvi_block_or},
View
@@ -56,6 +56,29 @@ off_t size;
/* Tools window */
WINDOW *tools_win = NULL;
+/* CORE structure */
+/*
+struct core {
+ struct params {
+ int COLUMNS_DATA;
+ int COLUMNS_HEX;
+ struct colors {}
+ }
+ struct editor {
+ PTR mem;
+ struct current {
+ PTR curpos;
+ PTR pagepos;
+ PTR spos;
+ }
+ PTR maxpos;
+ }
+ struct KEYMAP;
+ struct BLOCKS;
+ struct MARKERS;
+}
+*/
+
PTR mem = NULL;
PTR curpos;
PTR maxpos;
@@ -67,7 +90,7 @@ char string[MAXCMD];
char cmdstr[MAXCMD + 1] = "";
FILE *Ausgabe_Datei;
int edits = 0;
-int AnzAdd, Anzahl, Anzahl3;
+int AnzAdd, COLUMNS_DATA, COLUMNS_HEX;
off_t filesize, memsize, undosize;
long precount = -1; /* number preceding command */
@@ -134,12 +157,12 @@ void main_window_resize(int lines_count) {
AnzAdd = 10;
strcpy(addr_form, "%08lX%c:");
- Anzahl = ((COLS - AnzAdd - 1) / 16) * 4;
- P(P_CM) = Anzahl;
- maxx = Anzahl * 4 + AnzAdd + 1;
- Anzahl3 = Anzahl * 3;
- status = Anzahl3 + Anzahl - 17;
- screen = Anzahl * (maxy - 1);
+ COLUMNS_DATA = ((COLS - AnzAdd - 1) / 16) * 4;
+ P(P_CM) = COLUMNS_DATA;
+ maxx = COLUMNS_DATA * 4 + AnzAdd + 1;
+ COLUMNS_HEX = COLUMNS_DATA * 3;
+ status = COLUMNS_HEX + COLUMNS_DATA - 17;
+ screen = COLUMNS_DATA * (maxy - 1);
new_screen();
}
@@ -357,7 +380,7 @@ char *argv[];
/* main loop */
do {
setjmp(env);
- current = (PTR) (pagepos + y * Anzahl + xpos());
+ current = (PTR) (pagepos + y * COLUMNS_DATA + xpos());
if (wrstat)
statpos();
wrstat = 1;
@@ -385,12 +408,12 @@ char *argv[];
loc = HEX;
break;
/*
- case '0': x = AnzAdd + Anzahl3;
+ case '0': x = AnzAdd + COLUMNS_HEX;
loc = ASCII;
break;
*/
case '$':
- x = AnzAdd - 1 + Anzahl3 + Anzahl;
+ x = AnzAdd - 1 + COLUMNS_HEX + COLUMNS_DATA;
loc = ASCII;
break;
case '\t':
@@ -416,43 +439,43 @@ char *argv[];
if (loc == HEX)
x = AnzAdd;
else
- x = AnzAdd + Anzahl3;
+ x = AnzAdd + COLUMNS_HEX;
break;
case 'M':
y = maxy / 2;
if ((PTR) (pagepos + screen) > maxpos)
- y = (int)(maxpos - pagepos) / Anzahl / 2;
+ y = (int)(maxpos - pagepos) / COLUMNS_DATA / 2;
if (loc == HEX)
x = AnzAdd;
else
- x = AnzAdd + Anzahl3;
+ x = AnzAdd + COLUMNS_HEX;
break;
case KEY_LL:
case 'L':
if (precount < 1)
precount = 1;
n = maxy - 1;
if ((PTR) ((pagepos + screen)) > maxpos)
- n = (int)(maxpos - pagepos) / Anzahl;
+ n = (int)(maxpos - pagepos) / COLUMNS_DATA;
if (precount < n)
y = n + 1 - precount;
if (loc == HEX)
x = AnzAdd;
else
- x = AnzAdd + Anzahl3;
+ x = AnzAdd + COLUMNS_HEX;
break;
case BVICTRL('H'):
case KEY_BACKSPACE:
case KEY_LEFT:
case 'h':
do {
if (x > (AnzAdd + 2)
- && x < (Anzahl3 + AnzAdd + 1))
+ && x < (COLUMNS_HEX + AnzAdd + 1))
x -= 3;
- else if (x > (Anzahl3 + AnzAdd - 2))
+ else if (x > (COLUMNS_HEX + AnzAdd - 2))
x--;
} while (--precount > 0);
- if (x < AnzAdd + Anzahl3)
+ if (x < AnzAdd + COLUMNS_HEX)
loc = HEX;
else
loc = ASCII;
@@ -462,15 +485,15 @@ char *argv[];
case 'l':
do {
/*
- if (x < (Anzahl3 + 6)) x += 3;
+ if (x < (COLUMNS_HEX + 6)) x += 3;
*/
- if (x < (Anzahl3 + AnzAdd - 2))
+ if (x < (COLUMNS_HEX + AnzAdd - 2))
x += 3;
- else if (x > (Anzahl3 + 3)
- && x < (Anzahl3 + AnzAdd - 1 + Anzahl))
+ else if (x > (COLUMNS_HEX + 3)
+ && x < (COLUMNS_HEX + AnzAdd - 1 + COLUMNS_DATA))
x++;
} while (--precount > 0);
- if (x < AnzAdd + Anzahl3)
+ if (x < AnzAdd + COLUMNS_HEX)
loc = HEX;
else
loc = ASCII;
@@ -490,13 +513,13 @@ char *argv[];
if (loc == HEX)
x = AnzAdd;
else
- x = AnzAdd + Anzahl3;
+ x = AnzAdd + COLUMNS_HEX;
case 'j':
case BVICTRL('J'):
case BVICTRL('N'):
case KEY_DOWN:
do {
- if ((PTR) ((pagepos + (y + 1) * Anzahl)) >
+ if ((PTR) ((pagepos + (y + 1) * COLUMNS_DATA)) >
maxpos)
break;
if (y < (maxy - 1))
@@ -509,11 +532,11 @@ char *argv[];
if (precount < 1)
break;
if (loc == ASCII)
- x = AnzAdd - 1 + Anzahl3 + precount;
+ x = AnzAdd - 1 + COLUMNS_HEX + precount;
else
x = 5 + 3 * precount;
- if (x > AnzAdd - 1 + Anzahl3 + Anzahl) {
- x = AnzAdd - 1 + Anzahl3 + Anzahl;
+ if (x > AnzAdd - 1 + COLUMNS_HEX + COLUMNS_DATA) {
+ x = AnzAdd - 1 + COLUMNS_HEX + COLUMNS_DATA;
loc = ASCII;
}
break;
@@ -908,7 +931,7 @@ void trunc_cur()
undosize = filesize;
undo_count = (off_t) (maxpos - current);
undo_start = current;
- filesize = pagepos - mem + y * Anzahl + xpos();
+ filesize = pagepos - mem + y * COLUMNS_DATA + xpos();
maxpos = (PTR) (mem + filesize);
if (filesize == 0L) {
emsg(nobytes);
View
@@ -153,6 +153,7 @@ struct BLOCK_ {
unsigned long pos_end;
char name[64];
unsigned int hl_toggle; /* do we need highlight this block? */
+ unsigned short folding; /* do we need fold this block? */
unsigned int palette; /* pallete, which we are using for highlight this block */
};
@@ -169,7 +170,7 @@ extern int maxx, maxy, x, y;
extern int filemode, loc;
extern int edits, new;
extern int AnzAdd;
-extern int Anzahl, Anzahl3;
+extern int COLUMNS_DATA, COLUMNS_HEX;
extern int addr_flag;
extern int ignore_case, magic;
extern int screen, status;
Oops, something went wrong. Retry.

0 comments on commit 430811d

Please sign in to comment.