equal
deleted
inserted
replaced
766 if (num < w->hscroll.pos) w->hscroll.pos = num; |
766 if (num < w->hscroll.pos) w->hscroll.pos = num; |
767 } |
767 } |
768 |
768 |
769 static void DelChar(Textbuf *tb) |
769 static void DelChar(Textbuf *tb) |
770 { |
770 { |
771 tb->width -= GetCharacterWidth((byte)tb->buf[tb->caretpos]); |
771 tb->width -= GetCharacterWidth(FS_NORMAL, (byte)tb->buf[tb->caretpos]); |
772 memmove(tb->buf + tb->caretpos, tb->buf + tb->caretpos + 1, tb->length - tb->caretpos); |
772 memmove(tb->buf + tb->caretpos, tb->buf + tb->caretpos + 1, tb->length - tb->caretpos); |
773 tb->length--; |
773 tb->length--; |
774 } |
774 } |
775 |
775 |
776 /** |
776 /** |
782 */ |
782 */ |
783 bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
783 bool DeleteTextBufferChar(Textbuf *tb, int delmode) |
784 { |
784 { |
785 if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
785 if (delmode == WKC_BACKSPACE && tb->caretpos != 0) { |
786 tb->caretpos--; |
786 tb->caretpos--; |
787 tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]); |
787 tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, (byte)tb->buf[tb->caretpos]); |
788 |
788 |
789 DelChar(tb); |
789 DelChar(tb); |
790 return true; |
790 return true; |
791 } else if (delmode == WKC_DELETE && tb->caretpos < tb->length) { |
791 } else if (delmode == WKC_DELETE && tb->caretpos < tb->length) { |
792 DelChar(tb); |
792 DelChar(tb); |
815 * @param key Character to be inserted |
815 * @param key Character to be inserted |
816 * @return Return true on successfull change of Textbuf, or false otherwise |
816 * @return Return true on successfull change of Textbuf, or false otherwise |
817 */ |
817 */ |
818 bool InsertTextBufferChar(Textbuf *tb, byte key) |
818 bool InsertTextBufferChar(Textbuf *tb, byte key) |
819 { |
819 { |
820 const byte charwidth = GetCharacterWidth(key); |
820 const byte charwidth = GetCharacterWidth(FS_NORMAL, key); |
821 if (tb->length < (tb->maxlength - 1) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
821 if (tb->length < (tb->maxlength - 1) && (tb->maxwidth == 0 || tb->width + charwidth <= tb->maxwidth)) { |
822 memmove(tb->buf + tb->caretpos + 1, tb->buf + tb->caretpos, (tb->length - tb->caretpos) + 1); |
822 memmove(tb->buf + tb->caretpos + 1, tb->buf + tb->caretpos, (tb->length - tb->caretpos) + 1); |
823 tb->buf[tb->caretpos] = key; |
823 tb->buf[tb->caretpos] = key; |
824 tb->length++; |
824 tb->length++; |
825 tb->width += charwidth; |
825 tb->width += charwidth; |
842 { |
842 { |
843 switch (navmode) { |
843 switch (navmode) { |
844 case WKC_LEFT: |
844 case WKC_LEFT: |
845 if (tb->caretpos != 0) { |
845 if (tb->caretpos != 0) { |
846 tb->caretpos--; |
846 tb->caretpos--; |
847 tb->caretxoffs -= GetCharacterWidth((byte)tb->buf[tb->caretpos]); |
847 tb->caretxoffs -= GetCharacterWidth(FS_NORMAL, (byte)tb->buf[tb->caretpos]); |
848 return true; |
848 return true; |
849 } |
849 } |
850 break; |
850 break; |
851 case WKC_RIGHT: |
851 case WKC_RIGHT: |
852 if (tb->caretpos < tb->length) { |
852 if (tb->caretpos < tb->length) { |
853 tb->caretxoffs += GetCharacterWidth((byte)tb->buf[tb->caretpos]); |
853 tb->caretxoffs += GetCharacterWidth(FS_NORMAL, (byte)tb->buf[tb->caretpos]); |
854 tb->caretpos++; |
854 tb->caretpos++; |
855 return true; |
855 return true; |
856 } |
856 } |
857 break; |
857 break; |
858 case WKC_HOME: |
858 case WKC_HOME: |
881 tb->length = 0; |
881 tb->length = 0; |
882 tb->width = 0; |
882 tb->width = 0; |
883 |
883 |
884 for (buf = tb->buf; *buf != '\0' && tb->length < (tb->maxlength - 1); buf++) { |
884 for (buf = tb->buf; *buf != '\0' && tb->length < (tb->maxlength - 1); buf++) { |
885 tb->length++; |
885 tb->length++; |
886 tb->width += GetCharacterWidth((byte)*buf); |
886 tb->width += GetCharacterWidth(FS_NORMAL, (byte)*buf); |
887 } |
887 } |
888 |
888 |
889 tb->caretpos = tb->length; |
889 tb->caretpos = tb->length; |
890 tb->caretxoffs = tb->width; |
890 tb->caretxoffs = tb->width; |
891 } |
891 } |