00001 #include "editor.h"
00002
00003
00004 int show_dialog(const char *message, int x, int y, int width, int height)
00005 {
00006 draw_rect(x, y, width, height);
00007 draw_string(message, x+3, y+3);
00008 return read_char();
00009 }
00010
00011
00012
00013
00014 int dialog_read_string(const char *message, char *buffer, int x, int y,
00015 int width, int height)
00016 {
00017 int key;
00018 int string_pos = 0;
00019 draw_rect(x, y, width, height);
00020 draw_string(message, x+3, y+3);
00021
00022 do
00023 {
00024 draw_rect(x+3, y+height-11, width-7, 9);
00025 draw_string(buffer, x+5, y+height-9);
00026 key = read_char();
00027
00028 if(key==KEY_BACKSPACE || key==KEY_LEFT)
00029 {
00030 if(string_pos>0)
00031 buffer[--string_pos] = '\0';
00032 }
00033
00034 if(key==KEY_ENTER)
00035 return 1;
00036 if(key==KEY_ESC)
00037 return 0;
00038
00039
00040 if(key>0 && key<256)
00041 {
00042 buffer[string_pos++] = key;
00043 buffer[string_pos] = '\0';
00044 }
00045
00046 } while(1);
00047 }
00048
00049