Simplify the text window in SolveSpace; better scrolling behaviour,
and my concept is more like a web page than like a command line. [git-p4: depot-paths = "//depot/solvespace/": change = 1659]solver
parent
9c2a8a08dc
commit
3357446278
13
cmdline.cpp
13
cmdline.cpp
|
@ -25,7 +25,6 @@ void TextWindow::ClearScreen(void) {
|
|||
meta[i][j].link = NOT_A_LINK;
|
||||
}
|
||||
}
|
||||
row0 = 0;
|
||||
rows = 0;
|
||||
}
|
||||
|
||||
|
@ -33,14 +32,12 @@ void TextWindow::Printf(char *fmt, ...) {
|
|||
va_list vl;
|
||||
va_start(vl, fmt);
|
||||
|
||||
if(rows >= MAX_ROWS) return;
|
||||
|
||||
int r, c;
|
||||
if(rows < MAX_ROWS) {
|
||||
r = rows;
|
||||
rows++;
|
||||
} else {
|
||||
r = row0;
|
||||
row0++;
|
||||
}
|
||||
r = rows;
|
||||
rows++;
|
||||
|
||||
for(c = 0; c < MAX_COLS; c++) {
|
||||
text[r][c] = ' ';
|
||||
meta[r][c].link = NOT_A_LINK;
|
||||
|
|
2
ui.h
2
ui.h
|
@ -42,7 +42,7 @@ public:
|
|||
LinkFunction *f;
|
||||
} meta[MAX_ROWS][MAX_COLS];
|
||||
|
||||
int row0, rows;
|
||||
int rows;
|
||||
|
||||
void Init(void);
|
||||
void Printf(char *fmt, ...);
|
||||
|
|
|
@ -64,6 +64,9 @@ static void PaintTextWnd(HDC hdc)
|
|||
rows--;
|
||||
TextWndRows = rows;
|
||||
|
||||
TextWndScrollPos = min(TextWndScrollPos, SS.TW.rows - rows);
|
||||
TextWndScrollPos = max(TextWndScrollPos, 0);
|
||||
|
||||
// Let's set up the scroll bar first
|
||||
SCROLLINFO si;
|
||||
memset(&si, 0, sizeof(si));
|
||||
|
@ -79,22 +82,20 @@ static void PaintTextWnd(HDC hdc)
|
|||
for(r = TextWndScrollPos; r < (TextWndScrollPos+rows); r++) {
|
||||
if(r < 0) continue;
|
||||
if(r >= SS.TW.MAX_ROWS) continue;
|
||||
int rr = (r + SS.TW.row0);
|
||||
while(rr >= SS.TW.MAX_ROWS) rr -= SS.TW.MAX_ROWS;
|
||||
|
||||
for(c = 0; c < SS.TW.MAX_COLS; c++) {
|
||||
char v = '0' + (c % 10);
|
||||
int color = SS.TW.meta[rr][c].color;
|
||||
int color = SS.TW.meta[r][c].color;
|
||||
SetTextColor(backDc, SS.TW.colors[color].fg);
|
||||
SetBkColor(backDc, SS.TW.colors[color].bg);
|
||||
|
||||
if(SS.TW.meta[rr][c].link) {
|
||||
if(SS.TW.meta[r][c].link) {
|
||||
SelectObject(backDc, LinkFont);
|
||||
} else {
|
||||
SelectObject(backDc, FixedFont);
|
||||
}
|
||||
TextOut(backDc, 4 + c*TEXT_WIDTH, (r-TextWndScrollPos)*TEXT_HEIGHT,
|
||||
(char *)&(SS.TW.text[rr][c]), 1);
|
||||
(char *)&(SS.TW.text[r][c]), 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue