COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/light/cpp/DiffRender.cpp
Go to the documentation of this file.
00001 #include <coopy/DiffRender.h>
00002 
00003 using namespace coopy::light;
00004 using namespace std;
00005 
00006 bool DiffRender::render(const Table& table) {
00007   begin_table();
00008   int w = table.width();
00009   int h = table.height();
00010   int change_row = -1;
00011   for (int y=0; y<h; y++) {
00012     string row_mode = "";
00013     Cell cell = { "", true };
00014     bool open = false;
00015     if (w>0) {
00016       cell = table.get_cell(0,y);
00017       if (cell.txt=="@"||cell.txt=="@@") {
00018         row_mode = "@@";
00019       } else if (cell.txt=="!"||cell.txt=="+++"||cell.txt=="---"||cell.txt=="...") {
00020         row_mode = cell.txt;
00021         if (cell.txt=="!") { change_row = y; }
00022       } else if (cell.txt.find("->")!=string::npos) {
00023         row_mode = "->";
00024       } else {
00025         open = true;
00026       }
00027     }
00028     string cmd = cell.txt;
00029     begin_row(row_mode);
00030     for (int x=0; x<w; x++) {
00031       cell = table.get_cell(x,y);
00032       string cell_mode = "";
00033       string separator = "";
00034       if (open && change_row!=-1) {
00035         string change = table.get_cell(x,change_row).txt;
00036         if (change=="+++"||change=="---") {
00037           cell_mode = change;
00038         }
00039       }
00040       if (cmd.find("->")!=string::npos) {
00041         if (cell.txt.find(cmd)!=string::npos) {
00042           cell_mode = "->";
00043           separator = cmd;
00044         }
00045       }
00046       insert_cell(cell,cell_mode,separator);
00047     }
00048     end_row();
00049   }
00050   end_table();
00051   return true;
00052 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines