/[adonthell]/adonthell-0.3/src/label.cc
ViewVC logotype

Diff of /adonthell-0.3/src/label.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.10 by ksterker, Mon Oct 25 06:55:01 2004 UTC revision 1.11 by ksterker, Mon Dec 13 08:56:58 2004 UTC
# Line 559  bool label::update () Line 559  bool label::update ()
559  void label::cursor_draw ()  void label::cursor_draw ()
560  {  {
561       // draw the cursor       // draw the cursor
562      if (my_cursor_.idx == my_text_.length () || my_text_[my_cursor_.idx] == '\n')        u_int16 idx = my_cursor_.idx;
563        if (last_letter (idx)  || my_text_[idx] == '\n')  
564          my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,NULL, this);            my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,NULL, this);  
565      else      else
566          my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,0, 0,          my_font_->cursor->draw (my_cursor_.pos_x, my_cursor_.pos_y,0, 0,
567                                  (*my_font_) [ucd (my_cursor_.idx)].length (),                                  (*my_font_) [ucd (idx)].length (),
568                                  my_font_->height (), NULL, this);                                  my_font_->height (), NULL, this);
569  }  }
570    
   
   
571  void label::cursor_undraw ()  void label::cursor_undraw ()
572  {  {
573      // draw letter instead        // draw letter instead  
574      if (my_cursor_.idx == my_text_.length () || my_text_[my_cursor_.idx] == '\n')      u_int16 idx = my_cursor_.idx;
575        if (last_letter (idx) || my_text_[idx] == '\n')
576      {      {
577          lock ();          lock ();
578          fillrect(my_cursor_.pos_x, my_cursor_.pos_y,          fillrect(my_cursor_.pos_x, my_cursor_.pos_y,
# Line 581  void label::cursor_undraw () Line 581  void label::cursor_undraw ()
581                   screen::trans_col());                   screen::trans_col());
582          unlock ();          unlock ();
583      }      }
584      else (*my_font_) [ucd (my_cursor_.idx)].draw (my_cursor_.pos_x, my_cursor_.pos_y, NULL, this);      else (*my_font_) [ucd (idx)].draw (my_cursor_.pos_x, my_cursor_.pos_y, NULL, this);
585  }  }
586    
587    bool label::last_letter (u_int16 idx)
588    {
589        if ((u_int8) my_text_[idx] == 0xEF) return my_text_.length () - idx == 2;
590        if ((u_int8) my_text_[idx] == 0xC3) return my_text_.length () - idx == 1;
591        return my_cursor_.idx == my_text_.length ();
592    }
593    
594  bool label::input_update ()  bool label::input_update ()
595  {  {
596    
597      if(input::has_been_pushed(KEY_CURSOR_NEXT))      if(input::has_been_pushed(KEY_CURSOR_NEXT))
598      {      {
599          if (! (height () && length ())) return true;            if (! (height () && length ())) return false;  
600          cursor_undraw ();          // cursor_undraw ();
601          cursor_next ();          // cursor_next ();
602      }      }
603      else if (input::has_been_pushed(KEY_CURSOR_PREVIOUS))      else if (input::has_been_pushed(KEY_CURSOR_PREVIOUS))
604      {      {
605          if (! (height () && length ())) return false;            if (! (height () && length ())) return false;  
606          cursor_undraw ();            // cursor_undraw ();  
607          cursor_previous ();          // cursor_previous ();
608      }      }
609            
       
       
610      return true;      return true;
611  }  }
612    
# Line 611  void label::cursor_next () Line 616  void label::cursor_next ()
616      if (!moveable_cursor_) return;      if (!moveable_cursor_) return;
617      if (my_cursor_.idx < my_text_.length ())      if (my_cursor_.idx < my_text_.length ())
618      {      {
619          my_cursor_.idx++;          u_int8 count;
620            if (my_cursor_.idx < my_text_.length () - 2 && (u_int8) my_text_[my_cursor_.idx+1] == 0xEF) count = 3;
621            else if (my_cursor_.idx < my_text_.length () - 1 && (u_int8) my_text_[my_cursor_.idx+1] == 0xC3) count = 2;
622            else count = 1;
623            
624            my_cursor_.idx += count;
625          update_cursor ();          update_cursor ();
626      }      }
627  }  }
# Line 620  void label::cursor_next () Line 630  void label::cursor_next ()
630  void label::cursor_previous ()  void label::cursor_previous ()
631  {  {
632      if (!moveable_cursor_) return;      if (!moveable_cursor_) return;
633      if (my_cursor_.idx >0)      if (my_cursor_.idx > 0)
634      {      {
635          my_cursor_.idx--;          u_int8 count;
636            if (my_cursor_.idx > 2 && (u_int8) my_text_[my_cursor_.idx-3] == 0xEF) count = 3;
637            else if (my_cursor_.idx > 1 && (u_int8) my_text_[my_cursor_.idx-2] == 0xC3) count = 2;
638            else count = 1;
639    
640            my_cursor_.idx -= count;
641          update_cursor ();          update_cursor ();
642      }      }
643  }  }
# Line 658  u_int16 label::ucd (u_int16 & idx) Line 673  u_int16 label::ucd (u_int16 & idx)
673          |   (u_int16) (c2 ^ 0x80);          |   (u_int16) (c2 ^ 0x80);
674  }  }
675    
   
   
   
   
   
   

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26