#define MAX_YANK 1024
+#define DIRTY_ALL 0x01
+#define DIRTY_COMMAND 0x02
+#define DIRTY_MODE 0x04
+#define DIRTY_SCREEN 0x04
/*
* In-game editor of Object Auto-picker/Destoryer
bool edit_mode = FALSE;
- /*
- * dirty_line
- * 0,1,2,... : this line is dirty
- * -1 : perfectly clean
- * -2 : need redraw whole screen
- * -3 : mode is changed
- */
- int dirty_line = -2;
+ byte dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
+ int dirty_line = -1;
int wid, hgt, old_wid = -1, old_hgt = -1;
/* Redraw whole window after resize */
if (old_wid != wid || old_hgt != hgt)
+ dirty_flags |= DIRTY_SCREEN;
+
+ /* Redraw all text after scroll */
+ else if (old_upper != upper || old_left != left)
+ dirty_flags |= DIRTY_ALL;
+
+
+ if (dirty_flags & DIRTY_SCREEN)
{
- dirty_line = -2;
+ dirty_flags = DIRTY_ALL | DIRTY_COMMAND | DIRTY_MODE;
/* Clear screen */
Term_clear();
+ }
+ if (dirty_flags & DIRTY_COMMAND)
+ {
/* Display control command */
for (i = 0; ctrl_command_desc[i]; i++)
Term_putstr(wid - WID_DESC, i + 1, WID_DESC, TERM_WHITE, ctrl_command_desc[i]);
}
- /* Redraw all text after scroll */
- else if (old_upper != upper || old_left != left)
- dirty_line = -2;
- /* Redraw mode line unless perfectly clean */
- if (dirty_line != -1)
+ /* Redraw mode line */
+ if (dirty_line & DIRTY_MODE)
{
int sepa_length = wid - WID_DESC;
cptr msg;
/* clean or dirty? */
- if (dirty_line != -2 && dirty_line != upper+i)
+ if (!(dirty_flags & DIRTY_ALL) && (dirty_line != upper+i))
continue;
msg = lines_list[upper+i];
prt (format("(%d,%d)", cx, cy), 0, 70);
/* Display information when updated */
- if (old_cy != cy || dirty_line == -2 || dirty_line == cy)
+ if (old_cy != cy || (dirty_flags & DIRTY_ALL) || dirty_line == cy)
{
/* Clear information line */
Term_erase(0, hgt - 3 + 1, wid);
Term_gotoxy(cx - left, cy - upper + 1);
/* Now clean */
+ dirty_flags = 0;
dirty_line = -1;
/* Save old key and location */
edit_mode = FALSE;
/* Mode line is now dirty */
- dirty_line = -3;
+ dirty_flags |= DIRTY_MODE;
}
else if (!iscntrl(key&0xff))
{
edit_mode = TRUE;
/* Mode line is now dirty */
- dirty_line = -3;
+ dirty_flags |= DIRTY_MODE;
break;
case '~':
if (!autopick_new_entry(entry, lines_list[cy]))
cx = 0;
/* Now dirty */
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL;
break;
case KTRL('e'):
/* End of line */
if (!entry_from_object(entry))
{
/* Now dirty because of item/equip menu */
- dirty_line = -2;
+ dirty_flags |= DIRTY_SCREEN;
break;
}
tmp = autopick_line_from_entry(entry);
cx = 0;
/* Now dirty because of item/equip menu */
- dirty_line = -2;
+ dirty_flags |= DIRTY_SCREEN;
}
break;
case KTRL('l'):
cx = 0;
/* Now dirty */
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL;
}
break;
case '\n': case '\r':
cx = 0;
/* Now dirty */
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL;
break;
case KTRL('n'):
/* Next line */
/* Now dirty */
dirty_line = cy;
+ dirty_flags |= DIRTY_MODE;
break;
case KTRL('p'):
/* Previous line */
edit_mode = !edit_mode;
/* Mode line is now dirty */
- dirty_line = -3;
+ dirty_flags |= DIRTY_MODE;
break;
case KTRL('r'):
/* Revert to original */
free_text_lines(lines_list);
lines_list = read_pickpref_text_lines();
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL | DIRTY_MODE;
cx = cy = 0;
edit_mode = FALSE;
break;
}
/* Now dirty */
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL;
}
break;
case KTRL('z'):
cy--;
/* Now dirty */
- dirty_line = -2;
+ dirty_flags |= DIRTY_ALL;
break;
}