Exemple #1
0
static char keyboard_cmd(enum DrawCmds cmd, struct guiKeyboard *keyboard, struct touch *coords)
{
    char lastchar = keyboard->lastchar;
    struct guiBox box;
    const char * const *keys = array[keyboard->type];

    u8 row, i;
    char ch = '\0';
    for(row = 0; row < 4; row++) {
        const char *ptr = keys[row];
        u8 first = get_first_char(ptr);
        u8 last  = get_last_char(ptr);
        u8 num_chars = 1 + last - first;
        u16 x_off = (LCD_WIDTH - KEY_W1 * num_chars) / 2;
        u16 y_off = Y_OFFSET + KEY_H * row;

        for(i = 0; i < strlen(ptr); i++) {
            char c = ptr[i];
            if (c == '\x09') { //CAPS
                _make_box(&box, 0, Y_OFFSET + KEY_H * 2, KEY_W2, KEY_H);
            } else if (c == '\x08') { //DEL
                _make_box(&box, LCD_WIDTH - KEY_W2 -1, Y_OFFSET + KEY_H * 2, KEY_W2, KEY_H);
            } else if (c == '\x01' || c == '\x02') { //change KB type
                _make_box(&box, 0, Y_OFFSET + KEY_H * 3, KEY_W3, KEY_H);
            } else if (c == '\x06') { //DONE
                _make_box(&box, LCD_WIDTH - KEY_W3 -1, Y_OFFSET + KEY_H * 3, KEY_W3, KEY_H);
            } else if (c == ' ') { //SPACE
                _make_box(&box, KEY_W3, Y_OFFSET + KEY_H * 3, LCD_WIDTH - 2 * KEY_W3 -1, KEY_H);
            } else {
                _make_box(&box, x_off + (i - first) * KEY_W1, y_off, KEY_W1, KEY_H);
            }
            if (cmd == KB_DRAW) {
                if ((c == '\x01' || c == '\x02') && (lastchar == '\x01' || lastchar == '\x02'))
                    keyboard->lastchar = c;
                u8 pressed = c == keyboard->lastchar;
                kb_draw_key(&box, set_case(c, keyboard->flags & FLAG_CAPS), pressed);
            } else if (cmd == KB_RELEASE || cmd == KB_PRESS) {
                if(c == lastchar) {
                    kb_draw_key(&box, set_case(c, keyboard->flags & FLAG_CAPS), cmd == KB_PRESS);
                    return '\0';
                }
            } else if(cmd == KB_COMPARE_AND_PRESS) {
                if (coords_in_box(&box, coords)) {
                    kb_draw_key(&box, set_case(c, keyboard->flags & FLAG_CAPS), 1);
                    ch = c;
                } else if(c == lastchar) {
                    kb_draw_key(&box, set_case(c, keyboard->flags & FLAG_CAPS), 0);
                }
            }
        }
    }
    return ch;
}
Exemple #2
0
char		*ft_itoa(int n)
{
	char	*p;
	int		neg;
	int		nb_number;
	int		i;

	neg = is_neg(n);
	if (n == -2147483648)
		return (get_max_int_neg());
	if (neg)
		n = n * -1;
	nb_number = count_number(n);
	i = nb_number + neg;
	p = (char *) malloc(sizeof(char) * (nb_number + 1 + neg));
	p[i] = '\0';
	while (--i)
	{
		p[i] = n % 10 + 48;
		n = n / 10;
	}
	p[i] = get_first_char(neg, n);
	return (p);
}
Exemple #3
0
void list_bbs(char *directory, struct bbs_board_info *bbs_info,
   int num_files,struct bbs_user_account *bbs_user)
 {
  int file;
  int anyfile = 1;
  int key;
  int abort=0;
  char user_l[80];
  char date_l[80];
  char subject_l[120];
  char num_l[120];
  int count=0;

  FILE *fileptr;

  print_cr();
  file=num_files;

  while ((file>0) && (!abort))
   {
     file--;
     lock_dos();
     if (open_bbs_file(directory,bbs_info,file,&fileptr))
      {
        mail_line(user_l,20,40,fileptr);
        mail_line(subject_l,32,70,fileptr);
        mail_line(date_l,16,40,fileptr);
        g_fclose(fileptr);
        unlock_dos();
        anyfile = 0;
        if (bbs_info[file].filedate > (bbs_user->last_entered_bbs))
         sprintf(num_l,"*%02d: ",file+1);
         else
         sprintf(num_l," %02d: ",file+1);

        special_code(1,tswitch);

        print_string(num_l);
        print_string(user_l);
        print_chr(' ');
        print_string(date_l);
        print_chr(' ');
        print_string(subject_l);
        print_cr();
        count++;
        special_code(0,tswitch);

        key = get_first_char(tswitch);
        if ((key == 27) || (key == 3))
         {
           int_char(tswitch);
           file = -1;
         };
        if (key == 19)
         {
           wait_ch();
           wait_ch();
         };

        if (count>=24)
         { abort= do_page_break();
           count=0;
        }

        lock_dos();
      };
     unlock_dos();
   };
 if (anyfile) print_str_cr("No BBS messages.");
};
Exemple #4
0
void last_ten_callers(char *string, char *name, int portnum)
 {
   FILE *fileptr;
   char s[80];
   int num;
   int not_abort = 1;
   int key;
   char *data;
   int num_last = str_to_num(string,&data);

   if (num_last == -1) num_last = 10;
   if (num_last>99) num_last = 99;

   while( (*data==' ' || *data=='-' )&& *data!=0)
      data++;
   if (*data=='K' || *data=='k')
     {
     last_ten_kills(num_last,portnum);
     return;
     }




   print_cr();
   sprintf(s,"Last %d callers",num_last);
   print_str_cr(s);
   num_last++;
   print_cr();

   lock_dos(276);
   if (!(fileptr=g_fopen(USER_LOG_FILE,"rb","FILES#4")))       /* open the user log */
    {
      log_error(USER_LOG_FILE);
      unlock_dos();
      return;
    };
   call_on_logoff(close_last_ten_callers,(void *)fileptr);
   num = 1;
   while (not_abort && (num<num_last))
    {
      fseek(fileptr,-80*(long int)(num),SEEK_END);
      not_abort = (ftell(fileptr) != 0);
      if (not_abort)
       {
         sprintf(s,"%2d: ",num);
         unlock_dos();
         print_string(s);
         lock_dos(276);
         fread(s,1,80,fileptr);
         unlock_dos();
         print_str_cr(s);
         key = get_first_char(portnum);
         if ((key == 3) || (key == 27))
          {
            int_char(portnum);
            not_abort = 0;
          };
         lock_dos(277);
       };
      num++;
    };
   g_fclose(fileptr);
   clear_call_on_logoff();
   unlock_dos();
   print_cr();
 };