From: Ricardo Markiewicz Date: Wed, 19 Oct 2005 16:10:49 +0000 (+0000) Subject: Elimino visor curses. X-Git-Tag: 1_0-pre1~39 X-Git-Url: https://git.llucax.com/z.facultad/75.52/treemulator.git/commitdiff_plain/289c9edbf3c7b7180619535aaebfa269f5cd8bbd?ds=inline Elimino visor curses. Muy molesto de programar y debuggear. Lo sigo graficamente. --- diff --git a/nviewer/Makefile b/nviewer/Makefile deleted file mode 100644 index 15e718e..0000000 --- a/nviewer/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -TARGET=nviewer -CXXFLAGS=-Wall -g -I../src -OBJECTS=main.o window.o w_node_header.o w_btree.o w_ask.o - -all: $(TARGET) - -$(TARGET): $(OBJECTS) - g++ -o $(TARGET) $(OBJECTS) ../src/libbtree.a -lcurses - -clean: - rm -rf *.o $(TARGET) - - diff --git a/nviewer/main.cpp b/nviewer/main.cpp deleted file mode 100644 index 2f5f0f1..0000000 --- a/nviewer/main.cpp +++ /dev/null @@ -1,71 +0,0 @@ - -#include "window.h" -#include "w_btree.h" -#include "w_node_header.h" -#include "btree.h" -#include "random.h" -#include "w_ask.h" -#include - -int main (int argc, char *argv[]) -{ - std::list lst; - - BTree tree ("test.idx", 64); - - Random::Init (); - - Random::Ints (lst, 20); - - std::list::iterator it = lst.begin (); - while (it != lst.end ()) { - ClaveFija c(*it); - - tree.AddKey (c); - it++; - } - /* Inicio Curses */ - ///signal(SIGINT, finish); - initscr(); - keypad(stdscr, TRUE); - nonl(); - cbreak(); - noecho(); - curs_set (0); - - /* Si se soporta color, los inicializo */ - if (has_colors()) { - start_color(); - /* Simple color assignment, often all we need. */ - init_pair(COLOR_BLACK, COLOR_BLACK, COLOR_BLACK); /* COLOR_PAIR(1) */ - init_pair(COLOR_GREEN, COLOR_GREEN, COLOR_BLACK); - init_pair(COLOR_RED, COLOR_RED, COLOR_BLACK); - init_pair(COLOR_CYAN, COLOR_CYAN, COLOR_BLACK); - init_pair(COLOR_WHITE, COLOR_WHITE, COLOR_BLACK); - init_pair(COLOR_MAGENTA, COLOR_MAGENTA, COLOR_BLACK); - init_pair(COLOR_BLUE, COLOR_BLUE, COLOR_BLACK); - init_pair(COLOR_YELLOW, COLOR_YELLOW, COLOR_BLACK); - init_pair(COLOR_PAIR (1), COLOR_RED, COLOR_RED); - } - - /* Creo la ventana principal */ - Window *screen = new Window ("TreeMulator", 0, 0, 0, 0, true); - wBTree *wb = new wBTree (screen); - wAsk *ask = new wAsk (screen, "Proximo Nodo :"); - - wb->SetTree (&tree); - wb->ShowNode (0); - - screen->Show (); - wb->Show (); - - int node; - while ((node = ask->Node ()) != -1) { - wb->ShowNode (node); - } - - curs_set (1); - endwin(); - return 0; -} - diff --git a/nviewer/w_ask.cpp b/nviewer/w_ask.cpp deleted file mode 100644 index 920e820..0000000 --- a/nviewer/w_ask.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -#include "w_ask.h" - -wAsk::wAsk (Window *p, const std::string &s) : Window (p, s, p->Width ()-2, 3, 1, p->Height()-4) -{ -} - -#define MAX_ 50 - -uint wAsk::Node () -{ - uint pos = 0; - char arr[MAX_]; - int c; - - c = GetChar (); - while (c != 13) { - switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - case '-': - arr[pos++] = c; - break; - case 127: - pos--; - if (pos < 0) pos = 0; - } - SetText (1, 1, " "); - - mvwaddnstr (win, 1, 1, arr, pos); - Show (); - c = GetChar (); - } - - arr[pos] = '\0'; - return atoi (arr); -} - diff --git a/nviewer/w_ask.h b/nviewer/w_ask.h deleted file mode 100644 index 54a2687..0000000 --- a/nviewer/w_ask.h +++ /dev/null @@ -1,15 +0,0 @@ - -#ifndef _W_ASK_H_ -#define _W_ASK_H_ - -#include "window.h" - -class wAsk : public Window { - public: - wAsk (Window *p, const std::string &s); - - uint Node (); -}; - -#endif - diff --git a/nviewer/w_btree.cpp b/nviewer/w_btree.cpp deleted file mode 100644 index 2dbee00..0000000 --- a/nviewer/w_btree.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -#include -#include "w_btree.h" - -wBTree::wBTree (Window *p):Window (p, "", p->Width()-2, p->Height ()-5, 1, 1, true) -{ - last_length = 0; - wnode = new wNodeHeader (this, p->Width () - 30, 2); -} - -wBTree::~wBTree () -{ -} - -void wBTree::SetTree (BTree *b) -{ - tree = b; -} - -void wBTree::ShowNode (uint node_num) -{ - uchar *node; - std::list node_keys; - - node = tree->ReadBlock (node_num); - tree->ReadNodoHeader (node, &node_header); - node_keys = tree->ReadKeys (node, node_header); - - int y, x; - y = 8; - x = 2; - - for (uint o=0; o::iterator it = node_keys.begin (); - int n = 0; - while (it != node_keys.end ()) { - std::string s = *(*it); - - if ((x+s.length ()) > (width-4)) { - y++; - x = 2; - } - - if (n%2) - wattron (win, COLOR_PAIR (2)); - else - wattron (win, COLOR_PAIR (3)); - mvwaddnstr (win, y, x, " ", 1); - x++; - mvwaddnstr (win, y, x, (const char *)(s.c_str ()), s.length ()); - if (n%2) - wattroff (win, COLOR_PAIR (2)); - else - wattroff (win, COLOR_PAIR (3)); - x += s.length (); - n++; - it++; - } - last_length = x; - wnode->ShowHeader (node_num, node_header); - - Show (); -} - -void wBTree::Show () -{ - wnode->Show (); - Window::Show (); -} - diff --git a/nviewer/w_btree.h b/nviewer/w_btree.h deleted file mode 100644 index 9a8dcc9..0000000 --- a/nviewer/w_btree.h +++ /dev/null @@ -1,29 +0,0 @@ - - -#ifndef _W_B_TREE_ -#define _W_B_TREE_ - -#include "btree.h" -#include "window.h" -#include "w_node_header.h" - -class wBTree : public Window { - public: - wBTree (Window *p); - ~wBTree (); - - void SetTree (BTree *b); - void ShowNode (uint node_num); - BTreeNodeHeader& GetHeader () { return node_header; } - - virtual void Show (); - protected: - BTree *tree; - BTreeNodeHeader node_header; - uint last_length; - - wNodeHeader *wnode; -}; - -#endif - diff --git a/nviewer/w_node_header.cpp b/nviewer/w_node_header.cpp deleted file mode 100644 index 82e00a3..0000000 --- a/nviewer/w_node_header.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -#include "w_node_header.h" - -wNodeHeader::wNodeHeader (Window *p, int x, int y):Window (p, "Header", 25, 6, x, y) -{ - SetText (1, 1, "Nodo :"); - SetText (1, 2, "Nivel :"); - SetText (1, 3, "Libre :"); - SetText (1, 4, "Claves :"); -} - -void wNodeHeader::ShowHeader (uint node_num, BTreeNodeHeader &h) -{ - SetText (1, 1, "Nodo : "); - SetText (1, 2, "Nivel : "); - SetText (1, 3, "Libre : "); - SetText (1, 4, "Claves : "); - - SetText (10, 1, node_num); - - SetText (10, 2, h.level); - SetText (10, 3, h.free_space); - SetText (10, 4, h.item_count); -} - diff --git a/nviewer/w_node_header.h b/nviewer/w_node_header.h deleted file mode 100644 index f52c005..0000000 --- a/nviewer/w_node_header.h +++ /dev/null @@ -1,16 +0,0 @@ - -#ifndef _W_NODE_HEADER_ -#define _W_NODE_HEADER_ - -#include "btree.h" -#include "window.h" - -class wNodeHeader : public Window { - public: - wNodeHeader (Window *w, int x, int y); - - void ShowHeader (uint node_num, BTreeNodeHeader &h); -}; - -#endif - diff --git a/nviewer/window.cpp b/nviewer/window.cpp deleted file mode 100644 index 393e19c..0000000 --- a/nviewer/window.cpp +++ /dev/null @@ -1,88 +0,0 @@ - -#include "window.h" - -Window::Window (const std::string &s, int w, int h, int x, int y, bool use_box) -{ - parent = NULL; - if (!w) w = COLS; - if (!h) h = LINES; - - width = w; - height = h; - win = newwin (h, w, y, x); - - if (use_box == true) { - wattron (win, COLOR_PAIR (6)); - box(win, ACS_VLINE, ACS_HLINE); - wattroff (win, COLOR_PAIR (6)); - } - - title = s; - wattron (win, COLOR_PAIR (1)); - mvwaddstr(win, 0, 1, title.c_str ()); - wattroff (win, COLOR_PAIR (1)); -} - -Window::Window (Window *p, const std::string &s, int w, int h, int x, int y, bool use_box) -{ - parent = p; - if (!w) w = COLS; - if (!h) h = LINES; - - width = w; - height = h; - win = derwin (parent->win, h, w, y, x); - - if (use_box == true) { - wattron (win, COLOR_PAIR (6)); - box(win, ACS_VLINE, ACS_HLINE); - wattroff (win, COLOR_PAIR (6)); - } - - title = s; - wattron (win, COLOR_PAIR (1)); - mvwaddstr(win, 0, 1, title.c_str ()); - wattroff (win, COLOR_PAIR (1)); -} - -Window::~Window () -{ - delwin (win); -} - -void Window::SetText (int x, int y, const std::string &s) -{ - mvwaddstr (win, y, x, s.c_str ()); - Show (); -} - -void Window::SetText (int x, int y, int i) -{ - std::stringstream ss; - std::string s; - ss << i; - ss >> s; - SetText (x, y, s); -} - -void Window::SetText (int x, int y, uint i) -{ - std::stringstream ss; - std::string s; - ss << i; - ss >> s; - SetText (x, y, s); -} - -void Window::Show () -{ - if (parent) - touchwin (parent->win); - wrefresh (win); -} - -int Window::GetChar () -{ - return wgetch (win); -} - diff --git a/nviewer/window.h b/nviewer/window.h deleted file mode 100644 index ba749ab..0000000 --- a/nviewer/window.h +++ /dev/null @@ -1,32 +0,0 @@ - -#ifndef _WINDOW_H_ -#define _WINDOW_H_ - -#include -#include -#include - -class Window { - public: - Window (const std::string &s, int w, int h, int x=0, int y=0, bool box=true); - Window (Window *parent, const std::string &s, int w, int h, int x=0, int y=0, bool box=true); - virtual ~Window (); - - void SetText (int x, int y, const std::string &s); - void SetText (int x, int y, int i); - void SetText (int x, int y, uint i); - virtual void Show (); - int GetChar (); - - int Width () { return width; } - int Height () { return height; } - protected: - int width; - int height; - WINDOW *win; - std::string title; - Window *parent; -}; - -#endif -