3 #include "motordebugger.h"
7 uiwatcher::uiwatcher() {
11 uiwatcher::~uiwatcher() {
14 INT
uiwatcher::keyhandler(verticalmenu
&m
, INT k
) {
18 m
.clearonfocuslost
= false;
34 ws
= debugger
.getwatches();
36 debugger
.removewatch(*(ws
.begin()+m
.getpos()));
42 m
.clearonfocuslost
= true;
46 void uiwatcher::activate() {
50 ed
.resizebottom(uiconf
.getwatchlines());
52 m
= verticalmenu(uiconf
.getcolor(cp_menufr
), uiconf
.getcolor(cp_menusel
));
53 w
= textwindow(0, LINES
-uiconf
.getwatchlines()-1, COLS
-1, LINES
-2, uiconf
.getcolor(cp_menufr
));
57 m
.otherkeys
= &keyhandler
;
58 m
.clearonfocuslost
= true;
65 void uiwatcher::add() {
68 if(ui
.input(motorui::text
, buf
= ed
.atcursor(), _("Watch expression: "))
70 if(!debugger
.iswatch(buf
)) {
71 debugger
.addwatch(buf
);
81 void uiwatcher::modify(const string
&expr
, const string
&val
) {
84 if(ui
.input(motorui::text
, buf
= val
, _("change the value to: ")) == motorui::yes
) {
85 debugger
.setvar(expr
, buf
);
89 void uiwatcher::update() {
92 vector
<string
>::iterator iw
;
96 ws
= debugger
.getwatches();
98 for(iw
= ws
.begin(); iw
!= ws
.end(); iw
++) {
99 val
= debugger
.getvar(*iw
);
100 m
.additem(" " + *iw
+ ": " + (val
.empty() ? _("(not avail)") : val
));
107 void uiwatcher::exec() {
110 vector
<string
>::iterator iw
;
112 if(!visible()) activate();
114 ui
.log(_("Watches: ~Ins~ add, ~Del~ remove, ~^D~ close, ~A-W~ return to editor"));
118 if(!(i
= m
.open())) break;
120 if(debugger
.running() && i
) {
121 ws
= debugger
.getwatches();
123 modify(*iw
, debugger
.getvar(*iw
));
127 m
.getpos(startpos
, curpos
);
131 bool uiwatcher::visible() {
135 void uiwatcher::close() {