Debian Codegraph @

DiffView.h

raw symbols SCIP
1 //
2 // "$Id: DiffView.h 407 2006-11-13 18:54:02Z mike $"
3 //
4 // DiffView widget definitions.
5 //
6 // Copyright 2005-2006 by Michael Sweet.
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License v2 as published
10 // by the Free Software Foundation.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
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 // WIN32
29
30
31 //
32 // DiffView widget to view file differences...
33 //
34
35 class DiffView : public Fl_Group
36 {
37 enum
38 {
39 IDLE = 0, // Not doing anything
40 SCROLLING = 1, // Scrolling
41 SELECTING = 2, // Selecting text
42 UPARROW = 3, // Holding the up arrow
43 DOWNARROW = 4 // Holding the down arrow
44 };
45
46 struct DiffLine
47 {
48 char *left, // First file's line
49 *dleft, // Display version
50 *right, // Second file's line
51 *dright; // Display version
52 bool changed; // This line is changed?
53 int start, // Start of changes
54 end; // End of changes
55 };
56
57 int alloc_, // Allocated lines
58 count_; // Number of lines in buffer
59 bool directories_; // True if we are comparing directories
60 DiffLine **lines_; // Lines in buffer
61 char linefmt_[16]; // Line number format
62 int linenum_; // Width of line numbers
63 int maxwidth_; // Maximum width of lines
64 int select_start_, // Start of current selection
65 select_end_; // End of current selection
66 bool select_right_, // Select the right side?
67 showlinenum_, // Show line numbers?
68 ignoreblanks_; // ignore blanks during diff ?
69 int state_, // Scroll/selecting state
70 tabwidth_; // Width of tabs
71 Fl_Color textcolor_; // Text color
72 uchar textfont_, // Text font
73 textsize_; // Text size
74 int topline_; // Top position
75
76 Fl_Scrollbar hscroll1_, // Horizontal scrollbar for first file
77 hscroll2_; // Horizontal scrollbar for second file
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 // !_DiffView_h_
123
124 //
125 // End of "$Id: DiffView.h 407 2006-11-13 18:54:02Z mike $".
126 //