| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
#ifndef _DiffView_h_ |
| 19 |
# define _DiffView_h_ |
| 20 |
# include <FL/Fl.H> |
| 21 |
# include <FL/Fl_Group.H> |
| 22 |
# include <FL/Fl_Scrollbar.H> |
| 23 |
|
| 24 |
# if defined(WIN32) |
| 25 |
# include <io.h> |
| 26 |
# else |
| 27 |
# include <unistd.h> |
| 28 |
# endif |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
class DiffView : public Fl_Group |
| 36 |
{ |
| 37 |
enum |
| 38 |
{ |
| 39 |
IDLE = 0, |
| 40 |
SCROLLING = 1, |
| 41 |
SELECTING = 2, |
| 42 |
UPARROW = 3, |
| 43 |
DOWNARROW = 4 |
| 44 |
}; |
| 45 |
|
| 46 |
struct DiffLine |
| 47 |
{ |
| 48 |
char *left, |
| 49 |
*dleft, |
| 50 |
*right, |
| 51 |
*dright; |
| 52 |
bool changed; |
| 53 |
int start, |
| 54 |
end; |
| 55 |
}; |
| 56 |
|
| 57 |
int alloc_, |
| 58 |
count_; |
| 59 |
bool directories_; |
| 60 |
DiffLine **lines_; |
| 61 |
char linefmt_[16]; |
| 62 |
int linenum_; |
| 63 |
int maxwidth_; |
| 64 |
int select_start_, |
| 65 |
select_end_; |
| 66 |
bool select_right_, |
| 67 |
showlinenum_, |
| 68 |
ignoreblanks_; |
| 69 |
int state_, |
| 70 |
tabwidth_; |
| 71 |
Fl_Color textcolor_; |
| 72 |
uchar textfont_, |
| 73 |
textsize_; |
| 74 |
int topline_; |
| 75 |
|
| 76 |
Fl_Scrollbar hscroll1_, |
| 77 |
hscroll2_; |
| 78 |
|
| 79 |
void add_line(const char *left, const char *right, bool changed, |
| 80 |
int pos = -1); |
| 81 |
void draw(); |
| 82 |
char *expand_tabs(const char *s); |
| 83 |
static void scroll_cb(Fl_Scrollbar *s, DiffView *d); |
| 84 |
static void timeout_cb(DiffView *d); |
| 85 |
|
| 86 |
public: |
| 87 |
|
| 88 |
DiffView(int X, int Y, int W, int H, const char *L = 0); |
| 89 |
~DiffView(); |
| 90 |
|
| 91 |
void clear(); |
| 92 |
int count() const { return (count_); } |
| 93 |
bool directories() const { return (directories_); } |
| 94 |
int handle(int event); |
| 95 |
const char *left(int l) { return (lines_[l]->left); } |
| 96 |
bool line_changed(int l) { return (lines_[l]->changed); } |
| 97 |
bool load(const char *file1, const char *file2); |
| 98 |
void resize(int X, int Y, int W, int H); |
| 99 |
const char *right(int l) { return (lines_[l]->right); } |
| 100 |
void select(int s, int e, bool r); |
| 101 |
int select_end() const { return (select_end_); } |
| 102 |
int select_start() const { return (select_start_); } |
| 103 |
char *selection(); |
| 104 |
int selection_length(); |
| 105 |
void showline(int l); |
| 106 |
void showlinenum(bool b) { showlinenum_ = b; } |
| 107 |
bool showlinenum() const { return (showlinenum_); } |
| 108 |
void ignoreblanks(bool b) { ignoreblanks_ = b; } |
| 109 |
bool ignoreblanks() const { return (ignoreblanks_); } |
| 110 |
void tabwidth(int t) { tabwidth_ = t; } |
| 111 |
int tabwidth() const { return (tabwidth_); } |
| 112 |
void textcolor(Fl_Color c) { textcolor_ = c; } |
| 113 |
Fl_Color textcolor() const { return (textcolor_); } |
| 114 |
void textfont(uchar f) { textfont_ = f; } |
| 115 |
uchar textfont() const { return (textfont_); } |
| 116 |
void textsize(uchar s) { textsize_ = s; } |
| 117 |
uchar textsize() const { return (textsize_); } |
| 118 |
int topline() const { return (topline_ / textsize_); } |
| 119 |
}; |
| 120 |
|
| 121 |
|
| 122 |
#endif |
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|