Subversion Repositories SvarDOS

Rev

Rev 1321 | Rev 1323 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1321 Rev 1322
Line 38... Line 38...
38
 
38
 
39
#define COL_TXT        0
39
#define COL_TXT        0
40
#define COL_STATUSBAR1 1
40
#define COL_STATUSBAR1 1
41
#define COL_STATUSBAR2 2
41
#define COL_STATUSBAR2 2
42
#define COL_SCROLLBAR  3
42
#define COL_SCROLLBAR  3
-
 
43
#define COL_MSG        4
-
 
44
#define COL_ERR        5
43
/* preload the mono scheme (to be overloaded at runtime if color adapter present) */
45
/* preload the mono scheme (to be overloaded at runtime if color adapter present) */
44
static unsigned char scheme[] = {0x07, 0x70, 0x70, 0x70};
46
static unsigned char scheme[] = {0x07, 0x70, 0x70, 0x70, 0x70, 0x70};
45
 
47
 
46
#define SCROLL_CURSOR 0xB1
48
#define SCROLL_CURSOR 0xB1
47
 
49
 
48
 
50
 
49
struct line {
51
struct line {
Line 105... Line 107...
105
static void load_colorscheme(void) {
107
static void load_colorscheme(void) {
106
  scheme[COL_TXT] = 0x17;
108
  scheme[COL_TXT] = 0x17;
107
  scheme[COL_STATUSBAR1] = 0x70;
109
  scheme[COL_STATUSBAR1] = 0x70;
108
  scheme[COL_STATUSBAR2] = 0x78;
110
  scheme[COL_STATUSBAR2] = 0x78;
109
  scheme[COL_SCROLLBAR] = 0x70;
111
  scheme[COL_SCROLLBAR] = 0x70;
-
 
112
  scheme[COL_MSG] = 0x2f;
-
 
113
  scheme[COL_ERR] = 0x4f;
110
}
114
}
111
 
115
 
112
 
116
 
113
static void ui_basic(unsigned char screenw, unsigned char screenh, const struct file *db) {
117
static void ui_basic(unsigned char screenw, unsigned char screenh, const struct file *db) {
114
  unsigned char i;
118
  unsigned char i;
Line 140... Line 144...
140
    mdr_cout_char(i, screenw - 1, SCROLL_CURSOR, scheme[COL_SCROLLBAR]);
144
    mdr_cout_char(i, screenw - 1, SCROLL_CURSOR, scheme[COL_SCROLLBAR]);
141
  }
145
  }
142
}
146
}
143
 
147
 
144
 
148
 
145
static void ui_msg(const char *msg, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto) {
149
static void ui_msg(const char *msg, unsigned char screenw, unsigned char screenh, unsigned char *uidirtyfrom, unsigned char *uidirtyto, unsigned char attr) {
146
  unsigned short x, y, msglen, i;
150
  unsigned short x, y, msglen, i;
147
  msglen = strlen(msg);
151
  msglen = strlen(msg);
148
  y = (screenh - 4) >> 1;
152
  y = (screenh - 4) >> 1;
149
  x = (screenw - msglen - 4) >> 1;
153
  x = (screenw - msglen - 4) >> 1;
150
  for (i = y+2; i >= y; i--) mdr_cout_char_rep(i, x, ' ', scheme[COL_STATUSBAR1], msglen + 2);
154
  for (i = y+2; i >= y; i--) mdr_cout_char_rep(i, x, ' ', attr, msglen + 2);
151
  mdr_cout_str(y+1, x+1, msg, scheme[COL_STATUSBAR1], msglen);
155
  mdr_cout_str(y+1, x+1, msg, attr, msglen);
152
 
156
 
153
  if (*uidirtyfrom > y) *uidirtyfrom = y;
157
  if (*uidirtyfrom > y) *uidirtyfrom = y;
154
  if (*uidirtyto < y+2) *uidirtyto = y+2;
158
  if (*uidirtyto < y+2) *uidirtyto = y+2;
155
}
159
}
156
 
160
 
Line 617... Line 621...
617
      ui_help(screenw);
621
      ui_help(screenw);
618
      uidirtyfrom = 0;
622
      uidirtyfrom = 0;
619
      uidirtyto = 0xff;
623
      uidirtyto = 0xff;
620
 
624
 
621
    } else if (k == 0x13f) { /* F5 */
625
    } else if (k == 0x13f) { /* F5 */
-
 
626
      if (savefile(db) == 0) {
-
 
627
        ui_msg(svarlang_str(0, 2), screenw, screenh, &uidirtyfrom, &uidirtyto, scheme[COL_MSG]);
622
      const char *m[] = {"SAVED", "SAVING FILE FAILED"};
628
        mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
623
      int i;
629
      } else {
624
      i = !!savefile(db);
-
 
625
      ui_msg(m[i], screenw, screenh, &uidirtyfrom, &uidirtyto);
630
        ui_msg(svarlang_str(0, 3), screenw, screenh, &uidirtyfrom, &uidirtyto, scheme[COL_ERR]);
626
      mdr_bios_tickswait(11); /* 11 ticks is about 600 ms */
631
        mdr_bios_tickswait(36); /* 2s */
-
 
632
      }
627
 
633
 
628
    } else if (k == 0x144) { /* F10 */
634
    } else if (k == 0x144) { /* F10 */
629
      db->lfonly ^= 1;
635
      db->lfonly ^= 1;
630
      ui_basic(screenw, screenh, db);
636
      ui_basic(screenw, screenh, db);
631
 
637