diff --git a/plugins/zynaddsubfx/fltk/CHANGES b/plugins/zynaddsubfx/fltk/CHANGES index 4cddc8a63..79a3d0118 100644 --- a/plugins/zynaddsubfx/fltk/CHANGES +++ b/plugins/zynaddsubfx/fltk/CHANGES @@ -1,5 +1,11 @@ CHANGES IN FLTK 1.3.0 + - Corrected const methods of Fl_Text_{Buffer|Display|Selection} + to be declared const, corrected an Fl_Text_Buffer attrib. typo + - Fixed OpenGL shared context handling (STR #2135) + - Fixed gray-scale images with alpha channel (STR #2105) + - Fixed unexpected shortcut behavior for Win32 (STR #2199) + - Fixed documentation for Fl_Progress (STR #2209) - Fluid printing used wrong colors under Windows (STR #2195) - Updated documentation for Fl_Input_ - Fixed fl_draw_image to obey the alpha channel, hoping that diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H b/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H index fcd6bd745..afaa2f446 100644 --- a/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H +++ b/plugins/zynaddsubfx/fltk/FL/Fl_Clock.H @@ -42,7 +42,7 @@ #define FL_DIGITAL_CLOCK FL_SQUARE_CLOCK /**< Not yet implemented */ // fabien: Please keep the horizontal formatting of both images in class desc, -// don't loose vert. space for nothing! +// don't lose vert. space for nothing! /** \class Fl_Clock_Output @@ -109,7 +109,7 @@ public: Fl_Clock is provided for Forms compatibility. It installs a 1-second timeout callback using Fl::add_timeout(). - You can choose the rounded or square type of the the clock with type(), see below. + You can choose the rounded or square type of the clock with type(), see below. \htmlonly
type() FL_SQUARE_CLOCK and FL_ROUND_CLOCK
\endhtmlonly \image html clock.gif diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H index 6ad34e8fd..7efca467c 100644 --- a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H +++ b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Buffer.H @@ -51,20 +51,20 @@ class FL_EXPORT Fl_Text_Selection { void set(int start, int end); void set_rectangular(int start, int end, int rectStart, int rectEnd); void update(int pos, int nDeleted, int nInserted); - char rectangular() { return mRectangular; } - int start() { return mStart; } - int end() { return mEnd; } - int rect_start() { return mRectStart; } - int rect_end() { return mRectEnd; } + char rectangular() const { return mRectangular; } + int start() const { return mStart; } + int end() const { return mEnd; } + int rect_start() const { return mRectStart; } + int rect_end() const { return mRectEnd; } /** Returns a non-zero number if any text has been selected, or 0 if no text is selected. */ - char selected() { return mSelected; } + char selected() const { return mSelected; } void selected(char b) { mSelected = b; } - int includes(int pos, int lineStartPos, int dispIndex); - int position(int* start, int* end); - int position(int* start, int* end, int* isRect, int* rectStart, int* rectEnd); + int includes(int pos, int lineStartPos, int dispIndex) const; + int position(int* start, int* end) const; + int position(int* start, int* end, int* isRect, int* rectStart, int* rectEnd) const; protected: @@ -101,12 +101,12 @@ class FL_EXPORT Fl_Text_Buffer { ~Fl_Text_Buffer(); /** Returns the number of characters in the buffer. */ - int length() { return mLength; } - char* text(); + int length() const { return mLength; } + char* text() const; void text(const char* text); - char* text_range(int start, int end); - char character(int pos); - char* text_in_rectangle(int start, int end, int rectStart, int rectEnd); + char* text_range(int start, int end) const; + char character(int pos) const; + char* text_in_rectangle(int start, int end, int rectStart, int rectEnd) const; void insert(int pos, const char* text); /** Appends the text string to the end of the buffer. */ void append(const char* t) { insert(length(), t); } @@ -145,11 +145,11 @@ class FL_EXPORT Fl_Text_Buffer { void remove_rectangular(int start, int end, int rectStart, int rectEnd); void clear_rectangular(int start, int end, int rectStart, int rectEnd); /** Gets the tab width. */ - int tab_distance() { return mTabDist; } + int tab_distance() const { return mTabDist; } void tab_distance(int tabDist); void select(int start, int end); /** Returns a non 0 value if text has been selected, 0 otherwise */ - int selected() { return mPrimary.selected(); } + int selected() const { return mPrimary.selected(); } void unselect(); void select_rectangular(int start, int end, int rectStart, int rectEnd); int selection_position(int* start, int* end); @@ -210,48 +210,50 @@ class FL_EXPORT Fl_Text_Buffer { */ void call_predelete_callbacks() { call_predelete_callbacks(0, 0); } - char* line_text(int pos); - int line_start(int pos); - int line_end(int pos); - int word_start(int pos); - int word_end(int pos); - int expand_character(int pos, int indent, char *outStr); + char* line_text(int pos) const; + int line_start(int pos) const; + int line_end(int pos) const; + int word_start(int pos) const; + int word_end(int pos) const; + int expand_character(int pos, int indent, char *outStr) const; static int expand_character(char c, int indent, char* outStr, int tabDist, char nullSubsChar); static int character_width(char c, int indent, int tabDist, char nullSubsChar); - int count_displayed_characters(int lineStartPos, int targetPos); + int count_displayed_characters(int lineStartPos, int targetPos) const; int skip_displayed_characters(int lineStartPos, int nChars); - int count_lines(int startPos, int endPos); + int count_lines(int startPos, int endPos) const; int skip_lines(int startPos, int nLines); int rewind_lines(int startPos, int nLines); - int findchar_forward(int startPos, char searchChar, int* foundPos); - int findchar_backward(int startPos, char searchChar, int* foundPos); - int findchars_forward(int startPos, const char* searchChars, int* foundPos); - int findchars_backward(int startPos, const char* searchChars, int* foundPos); + int findchar_forward(int startPos, char searchChar, int* foundPos) const; + int findchar_backward(int startPos, char searchChar, int* foundPos) const; + int findchars_forward(int startPos, const char* searchChars, int* foundPos) const; + int findchars_backward(int startPos, const char* searchChars, int* foundPos) const; int search_forward(int startPos, const char* searchString, int* foundPos, - int matchCase = 0); + int matchCase = 0) const; int search_backward(int startPos, const char* searchString, int* foundPos, - int matchCase = 0); + int matchCase = 0) const; int substitute_null_characters(char* string, int length); void unsubstitute_null_characters(char* string); /** Returns the current nul substitution character. */ - char null_substitution_character() { return mNullSubsChar; } + char null_substitution_character() const { return mNullSubsChar; } + /** Returns the primary selection. */ + const Fl_Text_Selection* primary_selection() const { return &mPrimary; } /** Returns the primary selection. */ Fl_Text_Selection* primary_selection() { return &mPrimary; } /** Returns the secondary selection. */ - Fl_Text_Selection* secondary_selection() { return &mSecondary; } + const Fl_Text_Selection* secondary_selection() const { return &mSecondary; } /** Returns the current highlight selection. */ - Fl_Text_Selection* highlight_selection() { return &mHighlight; } + const Fl_Text_Selection* highlight_selection() const { return &mHighlight; } protected: void call_modify_callbacks(int pos, int nDeleted, int nInserted, - int nRestyled, const char* deletedText); - void call_predelete_callbacks(int pos, int nDeleted); + int nRestyled, const char* deletedText) const; + void call_predelete_callbacks(int pos, int nDeleted) const; int insert_(int pos, const char* text); void remove_(int start, int end); @@ -267,17 +269,17 @@ class FL_EXPORT Fl_Text_Buffer { int* nInserted, int* endPos); void redisplay_selection(Fl_Text_Selection* oldSelection, - Fl_Text_Selection* newSelection); + Fl_Text_Selection* newSelection) const; void move_gap(int pos); void reallocate_with_gap(int newGapStart, int newGapLen); - char* selection_text_(Fl_Text_Selection* sel); + char* selection_text_(Fl_Text_Selection* sel) const; void remove_selection_(Fl_Text_Selection* sel); void replace_selection_(Fl_Text_Selection* sel, const char* text); void rectangular_selection_boundaries(int lineStartPos, int rectStart, int rectEnd, int* selStart, - int* selEnd); + int* selEnd) const; void update_selections(int pos, int nDeleted, int nInserted); @@ -297,7 +299,7 @@ class FL_EXPORT Fl_Text_Buffer { tabs for padding in rectangular operations */ int mNModifyProcs; /**< number of modify-redisplay procs attached */ Fl_Text_Modify_Cb* /**< procedures to call when buffer is */ - mNodifyProcs; /**< modified to redisplay contents */ + mModifyProcs; /**< modified to redisplay contents */ void** mCbArgs; /**< caller arguments for modifyProcs above */ int mNPredeleteProcs; /**< number of pre-delete procs attached */ Fl_Text_Predelete_Cb* /**< procedure to call before text is deleted */ diff --git a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H index a76895a1a..2986b1cd7 100644 --- a/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H +++ b/plugins/zynaddsubfx/fltk/FL/Fl_Text_Display.H @@ -98,23 +98,23 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { Gets the current text buffer associated with the text widget. Multiple text widgets can be associated with the same text buffer. */ - Fl_Text_Buffer* buffer() { return mBuffer; } + Fl_Text_Buffer* buffer() const { return mBuffer; } void redisplay_range(int start, int end); void scroll(int topLineNum, int horizOffset); void insert(const char* text); void overstrike(const char* text); void insert_position(int newPos); /** Gets the position of the text insertion cursor for text display */ - int insert_position() { return mCursorPos; } - int in_selection(int x, int y); + int insert_position() const { return mCursorPos; } + int in_selection(int x, int y) const; void show_insert_position(); int move_right(); int move_left(); int move_up(); int move_down(); - int count_lines(int start, int end, bool start_pos_is_line_start); - int line_start(int pos); - int line_end(int pos, bool start_pos_is_line_start); + int count_lines(int start, int end, bool start_pos_is_line_start) const; + int line_start(int pos) const; + int line_end(int pos, bool start_pos_is_line_start) const; int skip_lines(int startPos, int nLines, bool startPosIsLineStart); int rewind_lines(int startPos, int nLines); void next_word(void); @@ -128,17 +128,17 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { /** Sets or gets the text cursor color. */ void cursor_color(Fl_Color n) {mCursor_color = n;} /** Sets or gets the width/height of the scrollbars. */ - int scrollbar_width() { return scrollbar_width_; } + int scrollbar_width() const { return scrollbar_width_; } /** Sets or gets the width/height of the scrollbars. */ void scrollbar_width(int W) { scrollbar_width_ = W; } /** Gets the scrollbar alignment type */ - Fl_Align scrollbar_align() { return scrollbar_align_; } + Fl_Align scrollbar_align() const { return scrollbar_align_; } /** Sets the scrollbar alignment type */ void scrollbar_align(Fl_Align a) { scrollbar_align_ = a; } /** Moves the insert position to the beginning of the current word. */ - int word_start(int pos) { return buffer()->word_start(pos); } + int word_start(int pos) const { return buffer()->word_start(pos); } /** Moves the insert position to the end of the current word. */ - int word_end(int pos) { return buffer()->word_end(pos); } + int word_end(int pos) const { return buffer()->word_end(pos); } void highlight_data(Fl_Text_Buffer *styleBuffer, @@ -148,7 +148,7 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { void *cbArg); int position_style(int lineStartPos, int lineLen, int lineIndex, - int dispIndex); + int dispIndex) const; /** \todo FIXME : get set methods pointing on shortcut_ have no effects as shortcut_ is unused in this class and derived! */ int shortcut() const {return shortcut_;} @@ -169,8 +169,8 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { /** Sets the default color of text in the widget. */ void textcolor(unsigned n) {textcolor_ = n;} - int wrapped_column(int row, int column); - int wrapped_row(int row); + int wrapped_column(int row, int column) const; + int wrapped_row(int row) const; void wrap_mode(int wrap, int wrap_margin); virtual void resize(int X, int Y, int W, int H); @@ -206,8 +206,8 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { void calc_last_char(); - int position_to_line( int pos, int* lineNum ); - int string_width(const char* string, int length, int style); + int position_to_line( int pos, int* lineNum ) const; + int string_width(const char* string, int length, int style) const; static void scroll_timer_cb(void*); @@ -220,22 +220,22 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { static void v_scrollbar_cb( Fl_Scrollbar* w, Fl_Text_Display* d); void update_v_scrollbar(); void update_h_scrollbar(); - int measure_vline(int visLineNum); - int longest_vline(); - int empty_vlines(); - int vline_length(int visLineNum); - int xy_to_position(int x, int y, int PosType = CHARACTER_POS); + int measure_vline(int visLineNum) const; + int longest_vline() const; + int empty_vlines() const; + int vline_length(int visLineNum) const; + int xy_to_position(int x, int y, int PosType = CHARACTER_POS) const; void xy_to_rowcol(int x, int y, int* row, int* column, - int PosType = CHARACTER_POS); + int PosType = CHARACTER_POS) const; - int position_to_xy(int pos, int* x, int* y); + int position_to_xy(int pos, int* x, int* y) const; void maintain_absolute_top_line_number(int state); - int get_absolute_top_line_number(); + int get_absolute_top_line_number() const; void absolute_top_line_number(int oldFirstChar); - int maintaining_absolute_top_line_number(); + int maintaining_absolute_top_line_number() const; void reset_absolute_top_line_number(); - int position_to_linecol(int pos, int* lineNum, int* column); + int position_to_linecol(int pos, int* lineNum, int* column) const; void scroll_(int topLineNum, int horizOffset); void extend_range_for_styles(int* start, int* end); @@ -248,13 +248,13 @@ class FL_EXPORT Fl_Text_Display: public Fl_Group { int maxLines, bool startPosIsLineStart, int styleBufOffset, int *retPos, int *retLines, int *retLineStart, int *retLineEnd, - bool countLastLineMissingNewLine = true); + bool countLastLineMissingNewLine = true) const; void find_line_end(int pos, bool start_pos_is_line_start, int *lineEnd, - int *nextLineStart); - int measure_proportional_character(char c, int colNum, int pos); - int wrap_uses_character(int lineEndPos); - int range_touches_selection(Fl_Text_Selection *sel, int rangeStart, - int rangeEnd); + int *nextLineStart) const; + int measure_proportional_character(char c, int colNum, int pos) const; + int wrap_uses_character(int lineEndPos) const; + int range_touches_selection(const Fl_Text_Selection *sel, int rangeStart, + int rangeEnd) const; #ifndef FL_DOXYGEN int damage_range1_start, damage_range1_end; int damage_range2_start, damage_range2_end; diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx index 631035802..79c8762b1 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Image.cxx @@ -465,7 +465,7 @@ void Fl_RGB_Image::draw(int XP, int YP, int WP, int HP, int cx, int cy) { CGDataProviderRelease(src); #elif defined(WIN32) id = fl_create_offscreen(w(), h()); - if (d() == 2 || d() == 4 && fl_can_do_alpha_blending()) { + if ((d() == 2 || d() == 4) && fl_can_do_alpha_blending()) { fl_begin_offscreen((Fl_Offscreen)id); fl_draw_image(array, 0, 0, w(), h(), d()|FL_IMAGE_WITH_ALPHA, ld()); fl_end_offscreen(); diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx index ef7a441d9..3868255b1 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Input_.cxx @@ -43,9 +43,9 @@ extern void fl_draw(const char*, int, float, float); //////////////////////////////////////////////////////////////// /** \internal - Convert a given text segment into the text that will be rendered on screen. + Converts a given text segment into the text that will be rendered on screen. - Copy the text from \p p to \p buf, replacing charcters with ^X + This copies the text from \p p to \p buf, replacing characters with ^X and \\nnn as necessary. The destination buffer is limited to \c MAXBUF (currently at 1024). All @@ -109,7 +109,7 @@ const char* Fl_Input_::expand(const char* p, char* buf) const { Calculates the width in pixels of part of a text buffer. This call takes a string, usually created by expand, and calculates - the width of the string when rendered with the give font. + the width of the string when rendered with the given font. \param [in] p pointer to the start of the original string \param [in] e pointer to the end of the original string @@ -149,10 +149,10 @@ double Fl_Input_::expandpos( //////////////////////////////////////////////////////////////// /** \internal - Mark a range of characters for update. + Marks a range of characters for update. This call marks all characters from \p to the end of the - text buffer for update. At least these chracters + text buffer for update. At least these characters will be redrawn in the next update cycle. Characters from \p mu_p to end of widget are redrawn. @@ -175,9 +175,9 @@ void Fl_Input_::minimal_update(int p) { } /** \internal - Mark a range of characters for update. + Marks a range of characters for update. - This call marks a text range for update. At least all chracters + This call marks a text range for update. At least all characters from \p p to \p q will be redrawn in the next update cycle. \param [in] p start of update range @@ -190,21 +190,21 @@ void Fl_Input_::minimal_update(int p, int q) { //////////////////////////////////////////////////////////////// -/* Horizontal cursor position in pixels while movin up or down. */ +/* Horizontal cursor position in pixels while moving up or down. */ double Fl_Input_::up_down_pos = 0; -/* Flag to remeber last cursor move. */ +/* Flag to remember last cursor move. */ int Fl_Input_::was_up_down = 0; /** - Set the current font and font size. + Sets the current font and font size. */ void Fl_Input_::setfont() const { fl_font(textfont(), textsize()); } /** - Draw the text in the passed bounding box. + Draws the text in the passed bounding box. If damage() & FL_DAMAGE_ALL is true, this assumes the area has already been erased to color(). Otherwise it does @@ -391,7 +391,7 @@ void Fl_Input_::drawtext(int X, int Y, int W, int H) { } /** \internal - Simple function that determins if a charcter could be part of a word. + Simple function that determines if a character could be part of a word. \todo This function is not ucs4-aware. */ static int isword(char c) { @@ -491,7 +491,7 @@ int Fl_Input_::line_start(int i) const { } /** - Handle mouse clicks and mouse moves. + Handles mouse clicks and mouse moves. \todo Add comment and parameters */ void Fl_Input_::handle_mouse(int X, int Y, int /*W*/, int /*H*/, int drag) { @@ -571,8 +571,8 @@ void Fl_Input_::handle_mouse(int X, int Y, int /*W*/, int /*H*/, int drag) { Sets the index for the cursor and mark. The input widget maintains two pointers into the string. The - \e position is where the cursor is. The - \e mark is the other end of the selected text. If they + \e position (\c p) is where the cursor is. The + \e mark (\c m) is the other end of the selected text. If they are equal then there is no selection. Changing this does not affect the clipboard (use copy() to do that). @@ -633,7 +633,7 @@ int Fl_Input_::position(int p, int m) { } /** - Move the cursor to the column given by \p up_down_pos. + Moves the cursor to the column given by \p up_down_pos. This function is helpful when implementing up and down cursor movement. It moves the cursor from the beginning @@ -667,12 +667,12 @@ int Fl_Input_::up_down_position(int i, int keepmark) { Put the current selection into the clipboard. This function copies the current selection between mark() and - position() into the specified clipboard. This does not + position() into the specified \c clipboard. This does not replace the old clipboard contents if position() and mark() are equal. Clipboard 0 maps to the current text selection and clipboard 1 maps to the cut/paste clipboard. - \param clipboard the clipboard destionation 0 or 1 + \param clipboard the clipboard destination 0 or 1 \return 0 if no text is selected, 1 if the selection was copied \see Fl::copy(const char *, int, int) */ @@ -719,11 +719,10 @@ static void undobuffersize(int n) { at that point and moves the mark() and position() to the end of the insertion. Does the callback if when() & FL_WHEN_CHANGED and there is a change. - - Set \p b and \p e equal to not delete - anything. Set insert to \c NULL to not insert - anything. - + + Set \p b and \p e equal to not delete anything. + Set insert to \c NULL to not insert anything. + \p ilen must be zero or strlen(insert), this saves a tiny bit of time if you happen to already know the length of the insertion, or can be used to insert a portion of a @@ -732,8 +731,7 @@ static void undobuffersize(int n) { \p b and \p e are clamped to the 0..size() range, so it is safe to pass any values. - cut() and insert() are just inline - functions that call replace(). + cut() and insert() are just inline functions that call replace(). \param [in] b beginning index of text to be deleted \param [in] e ending index of text to be deleted and insertion position @@ -837,7 +835,7 @@ int Fl_Input_::replace(int b, int e, const char* text, int ilen) { } /** - Undo previous changes to the text buffer. + Undoes previous changes to the text buffer. This call undoes a number of previous calls to replace(). @@ -884,10 +882,10 @@ int Fl_Input_::undo() { } /** - Copy the \e yank buffer to the clipboard. + Copies the \e yank buffer to the clipboard. - Copy all the previous contiguous cuts from the undo - information to the clipboard. This function implemnts + This method copies all the previous contiguous cuts from the undo + information to the clipboard. This function implements the \c ^K shortcut key. \return 0 if the operation did not change the clipboard @@ -901,7 +899,7 @@ int Fl_Input_::copy_cuts() { } /** \internal - Check the when() field and do a callback if indicated. + Checks the when() field and does a callback if indicated. */ void Fl_Input_::maybe_do_callback() { if (changed() || (when()&FL_WHEN_NOT_CHANGED)) { @@ -910,9 +908,9 @@ void Fl_Input_::maybe_do_callback() { } /** - Handle all kinds of text field related events. + Handles all kinds of text field related events. - This is calle by derived classes. + This is called by derived classes. \todo Add comment and parameters */ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) { @@ -1034,8 +1032,8 @@ int Fl_Input_::handletext(int event, int X, int Y, int W, int H) { /** Creates a new Fl_Input_ widget. - This function created a new Fl_Input_ widget and adds it to the curren - Fl_Group. The value() is set the \c NULL. + This function creates a new Fl_Input_ widget and adds it to the current + Fl_Group. The value() is set to \c NULL. The default boxtype is \c FL_DOWN_BOX. \param X, Y, W, H the dimensions of the new widget @@ -1061,7 +1059,7 @@ Fl_Input_::Fl_Input_(int X, int Y, int W, int H, const char* l) } /** - Copy the value from a possibly static entry into the internal buffer. + Copies the value from a possibly static entry into the internal buffer. \param [in] len size of the current text */ @@ -1103,7 +1101,7 @@ void Fl_Input_::put_in_buffer(int len) { /** Changes the widget text. - This function change the text and set the mark and the point to + This function changes the text and sets the mark and the point to the end of it. The string is \e not copied. If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and memory if your program is rapidly @@ -1151,7 +1149,7 @@ int Fl_Input_::static_value(const char* str, int len) { /** Changes the widget text. - This function change the text and set the mark and the point to + This function changes the text and sets the mark and the point to the end of it. The string is \e not copied. If the user edits the string it is copied to the internal buffer then. This can save a great deal of time and memory if your program is rapidly @@ -1203,7 +1201,7 @@ int Fl_Input_::value(const char* str) { } /** - Change the size of the widget. + Changes the size of the widget. This call updates the text layout so that the cursor is visible. \param [in] X, Y, W, H new size of the widget \see Fl_Widget::resize(int, int, int, int) @@ -1226,7 +1224,7 @@ Fl_Input_::~Fl_Input_() { } /** \internal - Return the number of lines displayed on a single page. + Returns the number of lines displayed on a single page. \return widget height divided by the font height */ int Fl_Input_::linesPerPage() { @@ -1242,9 +1240,9 @@ int Fl_Input_::linesPerPage() { /** Returns the character at index \p i. - This function returns the utf8 character at \p i + This function returns the UTF-8 character at \p i as a ucs4 character code. - + \param [in] i index into the value field \return the character at index \p i */ diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx index 2c1a3c8d8..9a3d4be08 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Menu_add.cxx @@ -28,10 +28,10 @@ // These are for Forms emulation and for dynamically changing the // menus. They are in this source file so they are not linked in if -// not used, which is what will happen if the the program only uses +// not used, which is what will happen if the program only uses // constant menu tables. -// Not at all guaranteed to be Forms compatable, especially with any +// Not at all guaranteed to be Forms compatible, especially with any // string with a % sign in it! #include diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx index bb00d60d2..227c90f57 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Progress.cxx @@ -47,7 +47,7 @@ // -// 'Fl_Progress::draw()' - Draw the check button. +// 'Fl_Progress::draw()' - Draw the progress bar. // /** Draws the progress bar. */ @@ -76,10 +76,10 @@ void Fl_Progress::draw() // Draw the box and label... if (progress > 0) { Fl_Color c = labelcolor(); - labelcolor(fl_contrast(labelcolor(), color2())); + labelcolor(fl_contrast(labelcolor(), selection_color())); fl_push_clip(x(), y(), progress + bx, h()); - draw_box(box(), x(), y(), w(), h(), active_r() ? color2() : fl_inactive(color2())); + draw_box(box(), x(), y(), w(), h(), active_r() ? selection_color() : fl_inactive(selection_color())); draw_label(tx, y() + by, tw, h() - bh); fl_pop_clip(); @@ -99,12 +99,16 @@ void Fl_Progress::draw() /** - The constructor creates the progress bar using the position, - size, and label. -

The inherited destructor removes the progress bar. + The constructor creates the progress bar using the position, size, and label. + + You can set the background color with color() and the + progress bar color with selection_color(), or you can set both colors + together with color(unsigned bg, unsigned sel). + + The default colors are FL_BACKGROUND2_COLOR and FL_YELLOW, resp. */ -Fl_Progress::Fl_Progress(int X, int Y, int W, int H, const char* l) -: Fl_Widget(X, Y, W, H, l) { +Fl_Progress::Fl_Progress(int X, int Y, int W, int H, const char* L) +: Fl_Widget(X, Y, W, H, L) { align(FL_ALIGN_INSIDE); box(FL_DOWN_BOX); color(FL_BACKGROUND2_COLOR, FL_YELLOW); diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx index ff36d20d5..91c33f4bc 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Text_Buffer.cxx @@ -47,7 +47,6 @@ static void deleteRectFromLine(const char *line, int rectStart, int rectEnd, static void overlayRectInLine(const char *line, char *insLine, int rectStart, int rectEnd, int tabDist, int useTabs, char nullSubsChar, char *outStr, int *outLen, int *endOffset); - static void addPadding(char *string, int startIndent, int toIndent, int tabDist, int useTabs, char nullSubsChar, int *charsAdded); static char *copyLine(const char* text, int *lineLen); @@ -122,7 +121,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) { mHighlight.mSelected = 0; mHighlight.mStart = mHighlight.mEnd = 0; mHighlight.mRectangular = 0; - mNodifyProcs = NULL; + mModifyProcs = NULL; mCbArgs = NULL; mNModifyProcs = 0; mNPredeleteProcs = 0; @@ -140,7 +139,7 @@ Fl_Text_Buffer::Fl_Text_Buffer(int requestedSize, int preferredGapSize) { Fl_Text_Buffer::~Fl_Text_Buffer() { free(mBuf); if (mNModifyProcs != 0) { - delete[] mNodifyProcs; + delete[] mModifyProcs; delete[] mCbArgs; } if (mNPredeleteProcs != 0) { @@ -153,10 +152,9 @@ Fl_Text_Buffer::~Fl_Text_Buffer() { Get the entire contents of a text buffer. Memory is allocated to contain the returned string, which the caller must free. */ -char * Fl_Text_Buffer::text() { - char *t; - - t = (char *)malloc(mLength + 1); +char * Fl_Text_Buffer::text() const { + char *t = (char *)malloc(mLength + 1); //UTF8: we alloc from a string len, but as (non-utf8 aware) strlen() + // is used to affect mLength, it is equal to buffer size - 1 and thus correct. memcpy(t, mBuf, mGapStart); memcpy(&t[ mGapStart ], &mBuf[ mGapEnd ], mLength - mGapStart); @@ -166,18 +164,15 @@ char * Fl_Text_Buffer::text() { /** Replaces the entire contents of the text buffer */ void Fl_Text_Buffer::text(const char *t) { - int insertedLength, deletedLength; - const char *deletedText; - call_predelete_callbacks(0, length()); /* Save information for redisplay, and get rid of the old buffer */ - deletedText = text(); - deletedLength = mLength; + const char *deletedText = text(); + int deletedLength = mLength; free((void *)mBuf); /* Start a new buffer with a gap of mPreferredGapSize in the center */ - insertedLength = strlen(t); + int insertedLength = strlen(t); mBuf = (char *)malloc(insertedLength + mPreferredGapSize); mLength = insertedLength; mGapStart = insertedLength / 2; @@ -202,9 +197,8 @@ void Fl_Text_Buffer::text(const char *t) { include the character pointed to by \p end. When you are done with the text, free it using the free() function. */ -char * Fl_Text_Buffer::text_range(int start, int end) { +char * Fl_Text_Buffer::text_range(int start, int end) const { char * s = NULL; - int copiedLength, part1Length; /* Make sure start and end are ok, and allocate memory for returned string. If start is bad, return "", if end is bad, adjust it. */ @@ -220,7 +214,7 @@ char * Fl_Text_Buffer::text_range(int start, int end) { } if (end > mLength) end = mLength; - copiedLength = end - start; + int copiedLength = end - start; s = (char *)malloc(copiedLength + 1); /* Copy the text from the buffer to the returned string */ @@ -229,7 +223,7 @@ char * Fl_Text_Buffer::text_range(int start, int end) { } else if (start >= mGapStart) { memcpy(s, &mBuf[ start + (mGapEnd - mGapStart) ], copiedLength); } else { - part1Length = mGapStart - start; + int part1Length = mGapStart - start; memcpy(s, &mBuf[ start ], part1Length); memcpy(&s[ part1Length ], &mBuf[ mGapEnd ], copiedLength - part1Length); } @@ -239,7 +233,7 @@ char * Fl_Text_Buffer::text_range(int start, int end) { /** Returns the character at the specified position pos in the buffer. Positions start at 0 */ -char Fl_Text_Buffer::character(int pos) { +char Fl_Text_Buffer::character(int pos) const { if (pos < 0 || pos >= mLength) return '\0'; if (pos < mGapStart) @@ -250,8 +244,6 @@ char Fl_Text_Buffer::character(int pos) { /** Inserts null-terminated string \p text at position \p pos. */ void Fl_Text_Buffer::insert(int pos, const char *text) { - int nInserted; - /* if pos is not contiguous to existing text, make it */ if (pos > mLength) pos = mLength; if (pos < 0) pos = 0; @@ -260,7 +252,7 @@ void Fl_Text_Buffer::insert(int pos, const char *text) { call_predelete_callbacks(pos, 0); /* insert and redisplay */ - nInserted = insert_(pos, text); + int nInserted = insert_(pos, text); mCursorPosHint = pos + nInserted; call_modify_callbacks(pos, 0, nInserted, 0, NULL); } @@ -269,19 +261,16 @@ void Fl_Text_Buffer::insert(int pos, const char *text) { Deletes the characters between \p start and \p end, and inserts the null-terminated string \p text in their place in the buffer. */ void Fl_Text_Buffer::replace(int start, int end, const char *text) { - const char * deletedText; - int nInserted; - // Range check... if (!text) return; if (start < 0) start = 0; if (end > mLength) end = mLength; call_predelete_callbacks(start, end-start); - deletedText = text_range(start, end); + const char * deletedText = text_range(start, end); remove_(start, end); //undoyankcut = undocut; - nInserted = insert_(start, text); + int nInserted = insert_(start, text); mCursorPosHint = start + nInserted; call_modify_callbacks(start, end - start, nInserted, 0, deletedText); free((void *)deletedText); @@ -289,8 +278,6 @@ void Fl_Text_Buffer::replace(int start, int end, const char *text) { /** Deletes a range of characters in the buffer.*/ void Fl_Text_Buffer::remove(int start, int end) { - const char * deletedText; - /* Make sure the arguments make sense */ if (start > end) { int temp = start; @@ -306,7 +293,7 @@ void Fl_Text_Buffer::remove(int start, int end) { call_predelete_callbacks(start, end-start); /* Remove and redisplay */ - deletedText = text_range(start, end); + const char * deletedText = text_range(start, end); remove_(start, end); mCursorPosHint = start; call_modify_callbacks(start, end - start, 0, 0, deletedText); @@ -320,7 +307,6 @@ void Fl_Text_Buffer::remove(int start, int end) { void Fl_Text_Buffer::copy(Fl_Text_Buffer *fromBuf, int fromStart, int fromEnd, int toPos) { int copiedLength = fromEnd - fromStart; - int part1Length; /* Prepare the buffer to receive the new text. If the new text fits in the current buffer, just move the gap (if necessary) to where @@ -340,7 +326,7 @@ void Fl_Text_Buffer::copy(Fl_Text_Buffer *fromBuf, int fromStart, &fromBuf->mBuf[ fromStart + (fromBuf->mGapEnd - fromBuf->mGapStart) ], copiedLength); } else { - part1Length = fromBuf->mGapStart - fromStart; + int part1Length = fromBuf->mGapStart - fromStart; memcpy(&mBuf[ toPos ], &fromBuf->mBuf[ fromStart ], part1Length); memcpy(&mBuf[ toPos + part1Length ], &fromBuf->mBuf[ fromBuf->mGapEnd ], copiedLength - part1Length); @@ -403,15 +389,13 @@ void Fl_Text_Buffer::canUndo(char flag) { */ void Fl_Text_Buffer::insert_column(int column, int startPos, const char *text, int *charsInserted, int *charsDeleted) { - int nLines, lineStartPos, nDeleted, insertDeleted, nInserted; - const char *deletedText; - - nLines = countLines(text); - lineStartPos = line_start(startPos); - nDeleted = line_end(skip_lines(startPos, nLines)) - + int nLines = countLines(text); + int lineStartPos = line_start(startPos); + int nDeleted = line_end(skip_lines(startPos, nLines)) - lineStartPos; call_predelete_callbacks(lineStartPos, nDeleted); - deletedText = text_range(lineStartPos, lineStartPos + nDeleted); + const char *deletedText = text_range(lineStartPos, lineStartPos + nDeleted); + int insertDeleted, nInserted; insert_column_(column, lineStartPos, text, &insertDeleted, &nInserted, &mCursorPosHint); if (nDeleted != insertDeleted) @@ -431,16 +415,14 @@ void Fl_Text_Buffer::insert_column(int column, int startPos, const char *text, in the operation (beginning at \p startPos) are returned in these arguments. */ void Fl_Text_Buffer::overlay_rectangular(int startPos, int rectStart, - int rectEnd, const char *text, int *charsInserted, int *charsDeleted) { - int nLines, lineStartPos, nDeleted, insertDeleted, nInserted; - const char *deletedText; + int rectEnd, const char *text, int *charsInserted, int *charsDeleted) { - nLines = countLines(text); - lineStartPos = line_start(startPos); - nDeleted = line_end(skip_lines(startPos, nLines)) - - lineStartPos; + int nLines = countLines(text); + int lineStartPos = line_start(startPos); + int nDeleted = line_end(skip_lines(startPos, nLines)) - lineStartPos; call_predelete_callbacks(lineStartPos, nDeleted); - deletedText = text_range(lineStartPos, lineStartPos + nDeleted); + const char *deletedText = text_range(lineStartPos, lineStartPos + nDeleted); + int insertDeleted, nInserted; overlay_rectangular_(lineStartPos, rectStart, rectEnd, text, &insertDeleted, &nInserted, &mCursorPosHint); if (nDeleted != insertDeleted) @@ -460,11 +442,7 @@ void Fl_Text_Buffer::overlay_rectangular(int startPos, int rectStart, */ void Fl_Text_Buffer::replace_rectangular(int start, int end, int rectStart, int rectEnd, const char *text) { - char *insPtr; - const char *deletedText; char *insText = (char *)""; - int i, nInsertedLines, nDeletedLines, insLen, hint; - int insertDeleted, insertInserted, deleteInserted; int linesPadded = 0; /* Make sure start and end refer to complete lines, since the @@ -480,26 +458,27 @@ void Fl_Text_Buffer::replace_rectangular(int start, int end, int rectStart, column. If more lines will be inserted than deleted, insert extra lines in the buffer at the end of the rectangle to make room for the additional lines in "text" */ - nInsertedLines = countLines(text); - nDeletedLines = count_lines(start, end); + int nInsertedLines = countLines(text); + int nDeletedLines = count_lines(start, end); if (nInsertedLines < nDeletedLines) { - insLen = strlen(text); + int insLen = strlen(text); insText = (char *)malloc(insLen + nDeletedLines - nInsertedLines + 1); strcpy(insText, text); - insPtr = insText + insLen; - for (i = 0; i < nDeletedLines - nInsertedLines; i++) + char *insPtr = insText + insLen; + for (int i = 0; i < nDeletedLines - nInsertedLines; i++) *insPtr++ = '\n'; *insPtr = '\0'; } else if (nDeletedLines < nInsertedLines) { linesPadded = nInsertedLines - nDeletedLines; - for (i = 0; i < linesPadded; i++) + for (int i = 0; i < linesPadded; i++) insert_(end, "\n"); } /* else nDeletedLines == nInsertedLines; */ /* Save a copy of the text which will be modified for the modify CBs */ - deletedText = text_range(start, end); + const char *deletedText = text_range(start, end); /* Delete then insert */ + int insertDeleted, insertInserted, deleteInserted, hint; remove_rectangular_(start, end, rectStart, rectEnd, &deleteInserted, &hint); insert_column_(rectStart, start, insText, &insertDeleted, &insertInserted, &mCursorPosHint); @@ -519,13 +498,12 @@ void Fl_Text_Buffer::replace_rectangular(int start, int end, int rectStart, */ void Fl_Text_Buffer::remove_rectangular(int start, int end, int rectStart, int rectEnd) { - const char * deletedText; - int nInserted; start = line_start(start); end = line_end(end); call_predelete_callbacks(start, end-start); - deletedText = text_range(start, end); + const char * deletedText = text_range(start, end); + int nInserted; remove_rectangular_(start, end, rectStart, rectEnd, &nInserted, &mCursorPosHint); call_modify_callbacks(start, end - start, nInserted, 0, deletedText); @@ -540,11 +518,9 @@ void Fl_Text_Buffer::remove_rectangular(int start, int end, int rectStart, */ void Fl_Text_Buffer::clear_rectangular(int start, int end, int rectStart, int rectEnd) { - int i, nLines; - char *newlineString; - - nLines = count_lines(start, end); - newlineString = (char *)malloc(nLines + 1); + int nLines = count_lines(start, end); + char *newlineString = (char *)malloc(nLines + 1); + int i; for (i = 0; i < nLines; i++) newlineString[ i ] = '\n'; newlineString[ i ] = '\0'; @@ -557,21 +533,18 @@ void Fl_Text_Buffer::clear_rectangular(int start, int end, int rectStart, with the text, free it using the free() function. */ char * Fl_Text_Buffer::text_in_rectangle(int start, int end, - int rectStart, int rectEnd) { - int lineStart, selLeft, selRight, len; - char *textOut, *outPtr, *retabbedStr; - const char *textIn; - + int rectStart, int rectEnd) const { start = line_start(start); end = line_end(end); - textOut = (char *)malloc((end - start) + 1); - lineStart = start; - outPtr = textOut; + char *textOut = (char *)malloc((end - start) + 1); + int lineStart = start; + char *outPtr = textOut; + int selLeft, selRight; while (lineStart <= end) { rectangular_selection_boundaries(lineStart, rectStart, rectEnd, &selLeft, &selRight); - textIn = text_range(selLeft, selRight); - len = selRight - selLeft; + const char *textIn = text_range(selLeft, selRight); + int len = selRight - selLeft; memcpy(outPtr, textIn, len); free((void *) textIn); outPtr += len; @@ -584,7 +557,8 @@ char * Fl_Text_Buffer::text_in_rectangle(int start, int end, /* If necessary, realign the tabs in the selection as if the text were positioned at the left margin */ - retabbedStr = realignTabs(textOut, rectStart, 0, mTabDist, + int len; + char *retabbedStr = realignTabs(textOut, rectStart, 0, mTabDist, mUseTabs, mNullSubsChar, &len); free((void *) textOut); return retabbedStr; @@ -595,8 +569,6 @@ char * Fl_Text_Buffer::text_in_rectangle(int start, int end, and used in computing offsets for rectangular selection operations. */ void Fl_Text_Buffer::tab_distance(int tabDist) { - const char * deletedText; - /* First call the pre-delete callbacks with the previous tab setting still active. */ call_predelete_callbacks(0, mLength); @@ -606,7 +578,7 @@ void Fl_Text_Buffer::tab_distance(int tabDist) { /* Force any display routines to redisplay everything (unfortunately, this means copying the whole buffer contents to provide "deletedText" */ - deletedText = text(); + const char * deletedText = text(); call_modify_callbacks(0, mLength, mLength, 0, deletedText); free((void *) deletedText); } @@ -635,15 +607,13 @@ void Fl_Text_Buffer::select_rectangular(int start, int end, int rectStart, } /** Gets the selection position */ -int Fl_Text_Buffer::selection_position(int *start, int *end - ) { +int Fl_Text_Buffer::selection_position(int *start, int *end) { return mPrimary.position(start, end); } /** Gets the selection position, and rectangular selection info */ int Fl_Text_Buffer::selection_position(int *start, int *end, int *isRect, int *rectStart, int *rectEnd) { - return mPrimary.position(start, end, isRect, rectStart, - rectEnd); + return mPrimary.position(start, end, isRect, rectStart, rectEnd); } /** @@ -770,36 +740,30 @@ char * Fl_Text_Buffer::highlight_text() { */ void Fl_Text_Buffer::add_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg) { - Fl_Text_Modify_Cb * newModifyProcs; - void **newCBArgs; - int i; - - newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs + 1 ]; - newCBArgs = new void * [ mNModifyProcs + 1 ]; - for (i = 0; i < mNModifyProcs; i++) { - newModifyProcs[ i + 1 ] = mNodifyProcs[ i ]; + Fl_Text_Modify_Cb * newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs + 1 ]; + void* *newCBArgs = new void* [ mNModifyProcs + 1 ]; + for (int i = 0; i < mNModifyProcs; i++) { + newModifyProcs[ i + 1 ] = mModifyProcs[ i ]; newCBArgs[ i + 1 ] = mCbArgs[ i ]; } if (mNModifyProcs != 0) { - delete [] mNodifyProcs; + delete [] mModifyProcs; delete [] mCbArgs; } newModifyProcs[ 0 ] = bufModifiedCB; newCBArgs[ 0 ] = cbArg; mNModifyProcs++; - mNodifyProcs = newModifyProcs; + mModifyProcs = newModifyProcs; mCbArgs = newCBArgs; } /** Removes a modify callback.*/ void Fl_Text_Buffer::remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, void *cbArg) { int i, toRemove = -1; - Fl_Text_Modify_Cb *newModifyProcs; - void **newCBArgs; /* find the matching callback to remove */ for (i = 0; i < mNModifyProcs; i++) { - if (mNodifyProcs[ i ] == bufModifiedCB && mCbArgs[ i ] == cbArg) { + if (mModifyProcs[ i ] == bufModifiedCB && mCbArgs[ i ] == cbArg) { toRemove = i; break; } @@ -814,40 +778,36 @@ void Fl_Text_Buffer::remove_modify_callback(Fl_Text_Modify_Cb bufModifiedCB, mNModifyProcs--; if (mNModifyProcs == 0) { mNModifyProcs = 0; - delete[] mNodifyProcs; - mNodifyProcs = NULL; + delete[] mModifyProcs; + mModifyProcs = NULL; delete[] mCbArgs; mCbArgs = NULL; return; } - newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs ]; - newCBArgs = new void * [ mNModifyProcs ]; + Fl_Text_Modify_Cb *newModifyProcs = new Fl_Text_Modify_Cb [ mNModifyProcs ]; + void * *newCBArgs = new void* [ mNModifyProcs ]; /* copy out the remaining members and free the old lists */ for (i = 0; i < toRemove; i++) { - newModifyProcs[ i ] = mNodifyProcs[ i ]; + newModifyProcs[ i ] = mModifyProcs[ i ]; newCBArgs[ i ] = mCbArgs[ i ]; } for (; i < mNModifyProcs; i++) { - newModifyProcs[ i ] = mNodifyProcs[ i + 1 ]; + newModifyProcs[ i ] = mModifyProcs[ i + 1 ]; newCBArgs[ i ] = mCbArgs[ i + 1 ]; } - delete[] mNodifyProcs; + delete[] mModifyProcs; delete[] mCbArgs; - mNodifyProcs = newModifyProcs; + mModifyProcs = newModifyProcs; mCbArgs = newCBArgs; } /** Adds a callback routine to be called before text is deleted from the buffer. */ void Fl_Text_Buffer::add_predelete_callback(Fl_Text_Predelete_Cb bufPreDeleteCB, void *cbArg) { - Fl_Text_Predelete_Cb *newPreDeleteProcs; - void **newCBArgs; - int i; - - newPreDeleteProcs = new Fl_Text_Predelete_Cb[ mNPredeleteProcs + 1 ]; - newCBArgs = new void * [ mNPredeleteProcs + 1 ]; - for (i = 0; i < mNPredeleteProcs; i++) { + Fl_Text_Predelete_Cb *newPreDeleteProcs = new Fl_Text_Predelete_Cb[ mNPredeleteProcs + 1 ]; + void* *newCBArgs = new void * [ mNPredeleteProcs + 1 ]; + for (int i = 0; i < mNPredeleteProcs; i++) { newPreDeleteProcs[i + 1] = mPredeleteProcs[i]; newCBArgs[i + 1] = mPredeleteCbArgs[i]; } @@ -866,9 +826,6 @@ void Fl_Text_Buffer::add_predelete_callback(Fl_Text_Predelete_Cb bufPreDeleteCB, void Fl_Text_Buffer::remove_predelete_callback( Fl_Text_Predelete_Cb bufPreDeleteCB, void *cbArg) { int i, toRemove = -1; - Fl_Text_Predelete_Cb *newPreDeleteProcs; - void **newCBArgs; - /* find the matching callback to remove */ for (i = 0; i < mNPredeleteProcs; i++) { if (mPredeleteProcs[i] == bufPreDeleteCB && @@ -893,8 +850,8 @@ void Fl_Text_Buffer::remove_predelete_callback( mPredeleteCbArgs = NULL; return; } - newPreDeleteProcs = new Fl_Text_Predelete_Cb [ mNPredeleteProcs ]; - newCBArgs = new void * [ mNPredeleteProcs ]; + Fl_Text_Predelete_Cb *newPreDeleteProcs = new Fl_Text_Predelete_Cb [ mNPredeleteProcs ]; + void* *newCBArgs = new void* [ mNPredeleteProcs ]; /* copy out the remaining members and free the old lists */ for (i = 0; i < toRemove; i++) { @@ -916,12 +873,12 @@ void Fl_Text_Buffer::remove_predelete_callback( character position. When you are done with the text, free it using the free() function. */ -char * Fl_Text_Buffer::line_text(int pos) { +char * Fl_Text_Buffer::line_text(int pos) const { return text_range(line_start(pos), line_end(pos)); } /** Returns the position of the start of the line containing position \p pos. */ -int Fl_Text_Buffer::line_start(int pos) { +int Fl_Text_Buffer::line_start(int pos) const { if (!findchar_backward(pos, '\n', &pos)) return 0; return pos + 1; @@ -931,13 +888,13 @@ int Fl_Text_Buffer::line_start(int pos) { (which is either a pointer to the newline character ending the line, or a pointer to one character beyond the end of the buffer) */ -int Fl_Text_Buffer::line_end(int pos) { +int Fl_Text_Buffer::line_end(int pos) const { if (!findchar_forward(pos, '\n', &pos)) pos = mLength; return pos; } /** Returns the position corresponding to the start of the word */ -int Fl_Text_Buffer::word_start(int pos) { +int Fl_Text_Buffer::word_start(int pos) const { while (pos && (isalnum(character(pos)) || character(pos) == '_')) { pos--; } @@ -946,7 +903,7 @@ int Fl_Text_Buffer::word_start(int pos) { } /** Returns the position corresponding to the end of the word.*/ -int Fl_Text_Buffer::word_end(int pos) { +int Fl_Text_Buffer::word_end(int pos) const { while (pos < length() && (isalnum(character(pos)) || character(pos) == '_')) { pos++; } @@ -963,10 +920,9 @@ int Fl_Text_Buffer::word_end(int pos) { for figuring tabs. Output string is guranteed to be shorter or equal in length to FL_TEXT_MAX_EXP_CHAR_LEN */ -int Fl_Text_Buffer::expand_character(int pos, int indent, char *outStr) { - int ret; +int Fl_Text_Buffer::expand_character(int pos, int indent, char *outStr) const { char c = character(pos); - ret = expand_character(c, indent, outStr, + int ret = expand_character(c, indent, outStr, mTabDist, mNullSubsChar); if (ret > 1 && (c & 0x80)) { int i; @@ -994,12 +950,10 @@ int Fl_Text_Buffer::expand_character(int pos, int indent, char *outStr) { */ int Fl_Text_Buffer::expand_character(char c, int indent, char *outStr, int tabDist, char nullSubsChar) { - int i, nSpaces; - /* Convert tabs to spaces */ if (c == '\t') { - nSpaces = tabDist - (indent % tabDist); - for (i = 0; i < nSpaces; i++) + int nSpaces = tabDist - (indent % tabDist); + for (int i = 0; i < nSpaces; i++) outStr[ i ] = ' '; return nSpaces; } @@ -1058,11 +1012,11 @@ int Fl_Text_Buffer::character_width(char c, int indent, int tabDist, char nullSu shown on the screen to represent characters in the buffer, where tabs and control characters are expanded) */ -int Fl_Text_Buffer::count_displayed_characters(int lineStartPos, int targetPos) { - int pos, charCount = 0; +int Fl_Text_Buffer::count_displayed_characters(int lineStartPos, int targetPos) const { + int charCount = 0; char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; - pos = lineStartPos; + int pos = lineStartPos; while (pos < targetPos) charCount += expand_character(pos++, charCount, expandedChar); return charCount; @@ -1074,11 +1028,10 @@ int Fl_Text_Buffer::count_displayed_characters(int lineStartPos, int targetPos) characters in the buffer, where tabs and control characters are expanded) */ int Fl_Text_Buffer::skip_displayed_characters(int lineStartPos, int nChars) { - int pos, charCount = 0; + int pos = lineStartPos; char c; - pos = lineStartPos; - while (charCount < nChars && pos < mLength) { + for (int charCount=0; charCount < nChars && pos < mLength;) { c = character(pos); if (c == '\n') return pos; @@ -1092,11 +1045,11 @@ int Fl_Text_Buffer::skip_displayed_characters(int lineStartPos, int nChars) { Counts the number of newlines between \p startPos and \p endPos in buffer. The character at position \p endPos is not counted. */ -int Fl_Text_Buffer::count_lines(int startPos, int endPos) { - int pos, gapLen = mGapEnd - mGapStart; +int Fl_Text_Buffer::count_lines(int startPos, int endPos) const { + int gapLen = mGapEnd - mGapStart; int lineCount = 0; - pos = startPos; + int pos = startPos; while (pos < mGapStart) { if (pos == endPos) return lineCount; @@ -1117,13 +1070,12 @@ int Fl_Text_Buffer::count_lines(int startPos, int endPos) { in the buffer and returns its position */ int Fl_Text_Buffer::skip_lines(int startPos, int nLines) { - int pos, gapLen = mGapEnd - mGapStart; - int lineCount = 0; - if (nLines == 0) return startPos; - pos = startPos; + int gapLen = mGapEnd - mGapStart; + int pos = startPos; + int lineCount = 0; while (pos < mGapStart) { if (mBuf[ pos++ ] == '\n') { lineCount++; @@ -1147,13 +1099,12 @@ int Fl_Text_Buffer::skip_lines(int startPos, int nLines) { that is a newline) in the buffer. \p nLines == 0 means find the beginning of the line */ int Fl_Text_Buffer::rewind_lines(int startPos, int nLines) { - int pos, gapLen = mGapEnd - mGapStart; - int lineCount = -1; - - pos = startPos - 1; + int pos = startPos - 1; if (pos <= 0) return 0; + int gapLen = mGapEnd - mGapStart; + int lineCount = -1; while (pos >= mGapStart) { if (mBuf[ pos + gapLen ] == '\n') { if (++lineCount >= nLines) @@ -1177,7 +1128,7 @@ int Fl_Text_Buffer::rewind_lines(int startPos, int nLines) { returns 1 if found, 0 if not. */ int Fl_Text_Buffer::search_forward(int startPos, const char *searchString, - int *foundPos, int matchCase) + int *foundPos, int matchCase) const { if (!searchString) return 0; int bp; @@ -1201,7 +1152,7 @@ int Fl_Text_Buffer::search_forward(int startPos, const char *searchString, returns 1 if found, 0 if not. */ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString, - int *foundPos, int matchCase) + int *foundPos, int matchCase) const { if (!searchString) return 0; int bp; @@ -1226,11 +1177,11 @@ int Fl_Text_Buffer::search_backward(int startPos, const char *searchString, returns 1 if found, 0 if not. */ int Fl_Text_Buffer::findchars_forward(int startPos, const char *searchChars, - int *foundPos) { - int pos, gapLen = mGapEnd - mGapStart; + int *foundPos) const { + int gapLen = mGapEnd - mGapStart; const char *c; - pos = startPos; + int pos = startPos; while (pos < mGapStart) { for (c = searchChars; *c != '\0'; c++) { if (mBuf[ pos ] == *c) { @@ -1260,15 +1211,15 @@ int Fl_Text_Buffer::findchars_forward(int startPos, const char *searchChars, returns 1 if found, 0 if not. */ int Fl_Text_Buffer::findchars_backward(int startPos, const char *searchChars, - int *foundPos) { - int pos, gapLen = mGapEnd - mGapStart; + int *foundPos) const { + int gapLen = mGapEnd - mGapStart; const char *c; if (startPos == 0) { *foundPos = 0; return 0; } - pos = startPos == 0 ? 0 : startPos - 1; + int pos = startPos == 0 ? 0 : startPos - 1; while (pos >= mGapStart) { for (c = searchChars; *c != '\0'; c++) { if (mBuf[ pos + gapLen ] == *c) { @@ -1367,13 +1318,8 @@ void Fl_Text_Buffer::unsubstitute_null_characters(char *string) { */ static void histogramCharacters(const char *string, int length, char hist[ 256 ], int init) { - int i; - const char *c; - - if (init) - for (i = 0; i < 256; i++) - hist[ i ] = 0; - for (c = string; c < &string[ length ]; c++) + if (init) memset(hist,0,sizeof(char)*256); // faster than the original per-char for loop + for (const char* c = string; c < &string[ length ]; c++) hist[ *((unsigned char *) c) ] |= 1; } @@ -1381,10 +1327,8 @@ static void histogramCharacters(const char *string, int length, char hist[ 256 ] Substitute fromChar with toChar in string. */ static void subsChars(char *string, int length, char fromChar, char toChar) { - char * c; - - for (c = string; c < &string[ length ]; c++) - if (*c == fromChar) * c = toChar; + for (char* c = string; c < &string[ length ]; c++) + if (*c == fromChar) *c = toChar; } /** @@ -1397,8 +1341,8 @@ static char chooseNullSubsChar(char hist[ 256 ]) { #define N_REPLACEMENTS 25 static char replacements[ N_REPLACEMENTS ] = {1, 2, 3, 4, 5, 6, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 28, 29, 30, 31, 11, 7}; - int i; - for (i = 0; i < N_REPLACEMENTS; i++) + + for (int i = 0; i < N_REPLACEMENTS; i++) if (hist[ replacements[ i ] ] == 0) return replacements[ i ]; return '\0'; @@ -1510,13 +1454,6 @@ void Fl_Text_Buffer::remove_(int start, int end) { */ void Fl_Text_Buffer::insert_column_(int column, int startPos, const char *insText, int *nDeleted, int *nInserted, int *endPos) { - int nLines, start, end, insWidth, lineStart, lineEnd; - int expReplLen, expInsLen, len, endOffset; - char *c, *outStr, *outPtr, *expText, *insLine; - const char *line; - const char *replText; - const char *insPtr; - if (column < 0) column = 0; @@ -1530,29 +1467,29 @@ void Fl_Text_Buffer::insert_column_(int column, int startPos, const char *insTex the text beyond the inserted column. (Space for additional newlines if the inserted text extends beyond the end of the buffer is counted with the length of insText) */ - start = line_start(startPos); - nLines = countLines(insText) + 1; - insWidth = textWidth(insText, mTabDist, mNullSubsChar); - end = line_end(skip_lines(start, nLines - 1)); - replText = text_range(start, end); - expText = expandTabs(replText, 0, mTabDist, mNullSubsChar, + int start = line_start(startPos); + int nLines = countLines(insText) + 1; + int insWidth = textWidth(insText, mTabDist, mNullSubsChar); + int end = line_end(skip_lines(start, nLines - 1)); + int expReplLen, expInsLen, len, endOffset; + const char* replText = text_range(start, end); + char* expText = expandTabs(replText, 0, mTabDist, mNullSubsChar, &expReplLen); free((void *) replText); free((void *) expText); expText = expandTabs(insText, 0, mTabDist, mNullSubsChar, &expInsLen); free((void *) expText); - outStr = (char *)malloc(expReplLen + expInsLen + + char* outStr = (char *)malloc(expReplLen + expInsLen + nLines * (column + insWidth + FL_TEXT_MAX_EXP_CHAR_LEN) + 1); /* Loop over all lines in the buffer between start and end removing the text between rectStart and rectEnd and padding appropriately. Trim trailing space from line (whitespace at the ends of lines otherwise tends to multiply, since additional padding is added to maintain it */ - outPtr = outStr; - lineStart = start; - insPtr = insText; - for (;;) { + char* outPtr = outStr, *insLine; + const char* insPtr = insText, *line; + for (int lineStart = start, lineEnd;;) { lineEnd = line_end(lineStart); line = text_range(lineStart, lineEnd); insLine = copyLine(insPtr, &len); @@ -1561,7 +1498,7 @@ void Fl_Text_Buffer::insert_column_(int column, int startPos, const char *insTex mUseTabs, mNullSubsChar, outPtr, &len, &endOffset); free((void *) line); free((void *) insLine); - for (c = outPtr + len - 1; c > outPtr && isspace(*c); c--) + for (const char *c = outPtr + len - 1; c > outPtr && isspace(*c); c--) len--; outPtr += len; *outPtr++ = '\n'; @@ -1593,29 +1530,26 @@ void Fl_Text_Buffer::insert_column_(int column, int startPos, const char *insTex */ void Fl_Text_Buffer::remove_rectangular_(int start, int end, int rectStart, int rectEnd, int *replaceLen, int *endPos) { - int nLines, lineStart, lineEnd, len, endOffset; - char *outStr, *outPtr, *expText; - const char *s, *line; - /* allocate a buffer for the replacement string large enough to hold possibly expanded tabs as well as an additional FL_TEXT_MAX_EXP_CHAR_LEN * 2 characters per line for padding where tabs and control characters cross the edges of the selection */ start = line_start(start); end = line_end(end); - nLines = count_lines(start, end) + 1; - s = text_range(start, end); - expText = expandTabs(s, 0, mTabDist, mNullSubsChar, &len); + int nLines = count_lines(start, end) + 1; + const char* s = text_range(start, end); + int len; + char* expText = expandTabs(s, 0, mTabDist, mNullSubsChar, &len); free((void *) s); free((void *) expText); - outStr = (char *)malloc(len + nLines * FL_TEXT_MAX_EXP_CHAR_LEN * 2 + 1); + char* outStr = (char *)malloc(len + nLines * FL_TEXT_MAX_EXP_CHAR_LEN * 2 + 1); /* loop over all lines in the buffer between start and end removing the text between rectStart and rectEnd and padding appropriately */ - lineStart = start; - outPtr = outStr; - endOffset = 0; - while (lineStart <= mLength && lineStart <= end) { + int endOffset = 0; + char* outPtr = outStr; + const char *line; + for (int lineStart=start,lineEnd; lineStart <= mLength && lineStart <= end;) { lineEnd = line_end(lineStart); line = text_range(lineStart, lineEnd); deleteRectFromLine(line, rectStart, rectEnd, mTabDist, @@ -1645,14 +1579,8 @@ void Fl_Text_Buffer::remove_rectangular_(int start, int end, int rectStart, column (as a hint for routines which need to set a cursor position). */ void Fl_Text_Buffer::overlay_rectangular_(int startPos, int rectStart, - int rectEnd, const char *insText, - int *nDeleted, int *nInserted, + int rectEnd, const char *insText,int *nDeleted, int *nInserted, int *endPos) { - int nLines, start, end, lineStart, lineEnd; - int expInsLen, len, endOffset; - char *c, *outStr, *outPtr, *expText, *insLine; - const char *line; - const char *insPtr; /* Allocate a buffer for the replacement string large enough to hold possibly expanded tabs in the inserted text, as well as per line: 1) @@ -1663,23 +1591,23 @@ void Fl_Text_Buffer::overlay_rectangular_(int startPos, int rectStart, must be padded to align the text beyond the inserted column. (Space for additional newlines if the inserted text extends beyond the end of the buffer is counted with the length of insText) */ - start = line_start(startPos); - nLines = countLines(insText) + 1; - end = line_end(skip_lines(start, nLines - 1)); - expText = expandTabs(insText, 0, mTabDist, mNullSubsChar, + int start = line_start(startPos); + int nLines = countLines(insText) + 1; + int end = line_end(skip_lines(start, nLines - 1)), expInsLen; + char* expText = expandTabs(insText, 0, mTabDist, mNullSubsChar, &expInsLen); free((void *) expText); - outStr = (char *)malloc(end - start + expInsLen + + char* outStr = (char *)malloc(end - start + expInsLen + nLines * (rectEnd + FL_TEXT_MAX_EXP_CHAR_LEN) + 1); /* Loop over all lines in the buffer between start and end overlaying the text between rectStart and rectEnd and padding appropriately. Trim trailing space from line (whitespace at the ends of lines otherwise tends to multiply, since additional padding is added to maintain it */ - outPtr = outStr; - lineStart = start; - insPtr = insText; - for (;;) { + int len, endOffset; + char* outPtr = outStr, *insLine; + const char* insPtr = insText,*line; + for (int lineStart = start,lineEnd;;) { lineEnd = line_end(lineStart); line = text_range(lineStart, lineEnd); insLine = copyLine(insPtr, &len); @@ -1688,7 +1616,7 @@ void Fl_Text_Buffer::overlay_rectangular_(int startPos, int rectStart, mUseTabs, mNullSubsChar, outPtr, &len, &endOffset); free((void *) line); free((void *) insLine); - for (c = outPtr + len - 1; c > outPtr && isspace(*c); c--) + for (const char* c = outPtr + len - 1; c > outPtr && isspace(*c); c--) len--; outPtr += len; *outPtr++ = '\n'; @@ -1721,13 +1649,11 @@ void Fl_Text_Buffer::overlay_rectangular_(int startPos, int rectStart, static void insertColInLine(const char *line, char *insLine, int column, int insWidth, int tabDist, int useTabs, char nullSubsChar, char *outStr, int *outLen, int *endOffset) { - char * c, *outPtr, *retabbedStr; - const char *linePtr; - int indent, toIndent, len, postColIndent; - /* copy the line up to "column" */ - outPtr = outStr; - indent = 0; + char* outPtr = outStr; + int indent = 0, len; + const char *linePtr; + for (linePtr = line; *linePtr != '\0'; linePtr++) { len = Fl_Text_Buffer::character_width(*linePtr, indent, tabDist, nullSubsChar); if (indent + len > column) @@ -1740,6 +1666,7 @@ static void insertColInLine(const char *line, char *insLine, int column, int ins tab, leave it off and leave the indent short and it will get padded later. If it's a control character, insert it and adjust indent accordingly. */ + int postColIndent; if (indent < column && *linePtr != '\0') { postColIndent = indent + len; if (*linePtr == '\t') @@ -1767,9 +1694,9 @@ static void insertColInLine(const char *line, char *insLine, int column, int ins /* Copy the text from "insLine" (if any), recalculating the tabs as if the inserted string began at column 0 to its new column destination */ if (*insLine != '\0') { - retabbedStr = realignTabs(insLine, 0, indent, tabDist, useTabs, + char* retabbedStr = realignTabs(insLine, 0, indent, tabDist, useTabs, nullSubsChar, &len); - for (c = retabbedStr; *c != '\0'; c++) { + for (const char* c = retabbedStr; *c != '\0'; c++) { *outPtr++ = *c; len = Fl_Text_Buffer::character_width(*c, indent, tabDist, nullSubsChar); indent += len; @@ -1785,13 +1712,13 @@ static void insertColInLine(const char *line, char *insLine, int column, int ins /* Pad out to column + width of inserted text + (additional original offset due to non-breaking character at column) */ - toIndent = column + insWidth + postColIndent - column; + int toIndent = column + insWidth + postColIndent - column; addPadding(outPtr, indent, toIndent, tabDist, useTabs, nullSubsChar, &len); outPtr += len; indent = toIndent; /* realign tabs for text beyond "column" and write it out */ - retabbedStr = realignTabs(linePtr, postColIndent, indent, tabDist, + char * retabbedStr = realignTabs(linePtr, postColIndent, indent, tabDist, useTabs, nullSubsChar, &len); strcpy(outPtr, retabbedStr); free((void *) retabbedStr); @@ -1811,13 +1738,11 @@ static void insertColInLine(const char *line, char *insLine, int column, int ins static void deleteRectFromLine(const char *line, int rectStart, int rectEnd, int tabDist, int useTabs, char nullSubsChar, char *outStr, int *outLen, int *endOffset) { - int indent, preRectIndent, postRectIndent, len; - const char *c; - char *retabbedStr, *outPtr; /* copy the line up to rectStart */ - outPtr = outStr; - indent = 0; + char* outPtr = outStr; + int indent = 0, len; + const char *c; for (c = line; *c != '\0'; c++) { if (indent > rectStart) break; @@ -1827,12 +1752,12 @@ static void deleteRectFromLine(const char *line, int rectStart, int rectEnd, indent += len; *outPtr++ = *c; } - preRectIndent = indent; + int preRectIndent = indent; /* skip the characters between rectStart and rectEnd */ for (; *c != '\0' && indent < rectEnd; c++) indent += Fl_Text_Buffer::character_width(*c, indent, tabDist, nullSubsChar); - postRectIndent = indent; + int postRectIndent = indent; /* If the line ended before rectEnd, there's nothing more to do */ if (*c == '\0') { @@ -1851,7 +1776,7 @@ static void deleteRectFromLine(const char *line, int rectStart, int rectEnd, /* Copy the rest of the line. If the indentation has changed, preserve the position of non-whitespace characters by converting tabs to spaces, then back to tabs with the correct offset */ - retabbedStr = realignTabs(c, postRectIndent, indent, tabDist, useTabs, + char* retabbedStr = realignTabs(c, postRectIndent, indent, tabDist, useTabs, nullSubsChar, &len); strcpy(outPtr, retabbedStr); free((void *) retabbedStr); @@ -1870,14 +1795,12 @@ static void deleteRectFromLine(const char *line, int rectStart, int rectEnd, static void overlayRectInLine(const char *line, char *insLine, int rectStart, int rectEnd, int tabDist, int useTabs, char nullSubsChar, char *outStr, int *outLen, int *endOffset) { - char * c, *outPtr, *retabbedStr; - int inIndent, outIndent, len, postRectIndent; - const char *linePtr; - /* copy the line up to "rectStart" */ - outPtr = outStr; - inIndent = outIndent = 0; - for (linePtr = line; *linePtr != '\0'; linePtr++) { + char *outPtr = outStr; + int inIndent=0, outIndent=0, len; + const char *linePtr=line; + + for (; *linePtr != '\0'; linePtr++) { len = Fl_Text_Buffer::character_width(*linePtr, inIndent, tabDist, nullSubsChar); if (inIndent + len > rectStart) break; @@ -1902,7 +1825,7 @@ static void overlayRectInLine(const char *line, char *insLine, int rectStart, } /* skip the characters between rectStart and rectEnd */ - postRectIndent = rectEnd; + int postRectIndent = rectEnd; for (; *linePtr != '\0'; linePtr++) { inIndent += Fl_Text_Buffer::character_width(*linePtr, inIndent, tabDist, nullSubsChar); if (inIndent >= rectEnd) { @@ -1929,9 +1852,9 @@ static void overlayRectInLine(const char *line, char *insLine, int rectStart, /* Copy the text from "insLine" (if any), recalculating the tabs as if the inserted string began at column 0 to its new column destination */ if (*insLine != '\0') { - retabbedStr = realignTabs(insLine, 0, rectStart, tabDist, useTabs, + char *retabbedStr = realignTabs(insLine, 0, rectStart, tabDist, useTabs, nullSubsChar, &len); - for (c = retabbedStr; *c != '\0'; c++) { + for (const char*c = retabbedStr; *c != '\0'; c++) { *outPtr++ = *c; len = Fl_Text_Buffer::character_width(*c, outIndent, tabDist, nullSubsChar); outIndent += len; @@ -1975,7 +1898,7 @@ void Fl_Text_Selection::set_rectangular(int startpos, int endpos, mRectEnd = rectEnd; } -int Fl_Text_Selection::position(int *startpos, int *endpos) { +int Fl_Text_Selection::position(int *startpos, int *endpos) const { if (!mSelected) return 0; *startpos = mStart; @@ -1985,7 +1908,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos) { } int Fl_Text_Selection::position(int *startpos, int *endpos, - int *isRect, int *rectStart, int *rectEnd) { + int *isRect, int *rectStart, int *rectEnd) const { if (!mSelected) return 0; *isRect = mRectangular; @@ -2002,7 +1925,7 @@ int Fl_Text_Selection::position(int *startpos, int *endpos, Return true if position \p pos with indentation \p dispIndex is in the Fl_Text_Selection. */ -int Fl_Text_Selection::includes(int pos, int lineStartPos, int dispIndex) { +int Fl_Text_Selection::includes(int pos, int lineStartPos, int dispIndex) const { return selected() && ((!rectangular() && pos >= start() && pos < end()) || (rectangular() && pos >= start() && lineStartPos <= end() && @@ -2012,13 +1935,12 @@ int Fl_Text_Selection::includes(int pos, int lineStartPos, int dispIndex) { -char * Fl_Text_Buffer::selection_text_(Fl_Text_Selection *sel) { +char * Fl_Text_Buffer::selection_text_(Fl_Text_Selection *sel) const { int start, end, isRect, rectStart, rectEnd; - char *s; /* If there's no selection, return an allocated empty string */ if (!sel->position(&start, &end, &isRect, &rectStart, &rectEnd)) { - s = (char *)malloc(1); + char *s = (char *)malloc(1); *s = '\0'; return s; } @@ -2031,8 +1953,7 @@ char * Fl_Text_Buffer::selection_text_(Fl_Text_Selection *sel) { } /** Removes the text from the buffer corresponding to \p sel.*/ void Fl_Text_Buffer::remove_selection_(Fl_Text_Selection *sel) { - int start, end; - int isRect, rectStart, rectEnd; + int start, end, isRect, rectStart, rectEnd; if (!sel->position(&start, &end, &isRect, &rectStart, &rectEnd)) return; @@ -2047,10 +1968,10 @@ void Fl_Text_Buffer::remove_selection_(Fl_Text_Selection *sel) { /** Replaces the \p text in selection \p sel.*/ void Fl_Text_Buffer::replace_selection_(Fl_Text_Selection *sel, const char *text) { - int start, end, isRect, rectStart, rectEnd; Fl_Text_Selection oldSelection = *sel; /* If there's no selection, return */ + int start, end, isRect, rectStart, rectEnd; if (!sel->position(&start, &end, &isRect, &rectStart, &rectEnd)) return; @@ -2068,13 +1989,11 @@ void Fl_Text_Buffer::replace_selection_(Fl_Text_Selection *sel, const char *text static void addPadding(char *string, int startIndent, int toIndent, int tabDist, int useTabs, char nullSubsChar, int *charsAdded) { - char * outPtr; - int len, indent; + int indent = startIndent, len; + char *outPtr = string; - indent = startIndent; - outPtr = string; if (useTabs) { - while (indent < toIndent) { + while(indent < toIndent) { len = Fl_Text_Buffer::character_width('\t', indent, tabDist, nullSubsChar); if (len > 1 && indent + len <= toIndent) { *outPtr++ = '\t'; @@ -2098,11 +2017,9 @@ static void addPadding(char *string, int startIndent, int toIndent, changed area(s) on the screen and any other listeners. */ void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted, - int nInserted, int nRestyled, const char *deletedText) { - int i; - - for (i = 0; i < mNModifyProcs; i++) - (*mNodifyProcs[ i ]) (pos, nInserted, nDeleted, nRestyled, + int nInserted, int nRestyled, const char *deletedText) const { + for (int i = 0; i < mNModifyProcs; i++) + (*mModifyProcs[ i ]) (pos, nInserted, nDeleted, nRestyled, deletedText, mCbArgs[ i ]); } @@ -2110,10 +2027,8 @@ void Fl_Text_Buffer::call_modify_callbacks(int pos, int nDeleted, Calls the stored pre-delete callback procedure(s) for this buffer to update the changed area(s) on the screen and any other listeners. */ -void Fl_Text_Buffer::call_predelete_callbacks(int pos, int nDeleted) { - int i; - - for (i=0; i= mLength) { *foundPos = mLength; return 0; } - pos = startPos; + int pos = startPos; while (pos < mGapStart) { if (mBuf[ pos ] == searchChar) { *foundPos = pos; @@ -2288,12 +2199,12 @@ int Fl_Text_Buffer::findchar_forward(int startPos, char searchChar, } pos++; } - while (pos < mLength) { + + for(int gapLen = mGapEnd - mGapStart; pos < mLength; pos++) { if (mBuf[ pos + gapLen ] == searchChar) { *foundPos = pos; return 1; } - pos++; } *foundPos = mLength; return 0; @@ -2308,27 +2219,26 @@ int Fl_Text_Buffer::findchar_forward(int startPos, char searchChar, count lines quickly, hence searching for a single character: newline) */ int Fl_Text_Buffer::findchar_backward(int startPos, char searchChar, - int *foundPos) { - int pos, gapLen = mGapEnd - mGapStart; + int *foundPos) const{ if (startPos <= 0 || startPos > mLength) { *foundPos = 0; return 0; } - pos = startPos - 1; - while (pos >= mGapStart) { + + int pos = startPos - 1; + for (int gapLen = mGapEnd - mGapStart; pos >= mGapStart; pos--) { if (mBuf[ pos + gapLen ] == searchChar) { *foundPos = pos; return 1; } - pos--; } - while (pos >= 0) { + + for (; pos >= 0; pos--) { if (mBuf[ pos ] == searchChar) { *foundPos = pos; return 1; } - pos--; } *foundPos = 0; return 0; @@ -2341,12 +2251,10 @@ int Fl_Text_Buffer::findchar_backward(int startPos, char searchChar, */ static char *copyLine(const char *text, int *lineLen) { int len = 0; - const char *c; - char *outStr; - for (c = text; *c != '\0' && *c != '\n'; c++) + for (const char *c = text; *c != '\0' && *c != '\n'; c++) len++; - outStr = (char *)malloc(len + 1); + char* outStr = (char *)malloc(len + 1); strlcpy(outStr, text, len + 1); *lineLen = len; return outStr; @@ -2356,10 +2264,9 @@ static char *copyLine(const char *text, int *lineLen) { Counts the number of newlines in a null-terminated text string; */ static int countLines(const char *string) { - const char * c; int lineCount = 0; - for (c = string; *c != '\0'; c++) + for (const char * c = string; *c != '\0'; c++) if (*c == '\n') lineCount++; return lineCount; } @@ -2369,9 +2276,8 @@ static int countLines(const char *string) { */ static int textWidth(const char *text, int tabDist, char nullSubsChar) { int width = 0, maxWidth = 0; - const char *c; - for (c = text; *c != '\0'; c++) { + for (const char *c = text; *c != '\0'; c++) { if (*c == '\n') { if (width > maxWidth) maxWidth = width; @@ -2399,7 +2305,7 @@ static int textWidth(const char *text, int tabDist, char nullSubsChar) { margin for subsequent columnar pastes of this data. */ void Fl_Text_Buffer::rectangular_selection_boundaries(int lineStartPos, - int rectStart, int rectEnd, int *selStart, int *selEnd) { + int rectStart, int rectEnd, int *selStart, int *selEnd) const { int pos, width, indent = 0; char c; @@ -2444,10 +2350,9 @@ void Fl_Text_Buffer::rectangular_selection_boundaries(int lineStartPos, */ static char *realignTabs(const char *text, int origIndent, int newIndent, int tabDist, int useTabs, char nullSubsChar, int *newLength) { - char * expStr, *outStr; - int len; - /* If the tabs settings are the same, retain original tabs */ + int len; + char *outStr; if (origIndent % tabDist == newIndent % tabDist) { len = strlen(text); outStr = (char *)malloc(len + 1); @@ -2458,7 +2363,7 @@ static char *realignTabs(const char *text, int origIndent, int newIndent, /* If the tab settings are not the same, brutally convert tabs to spaces, then back to tabs in the new position */ - expStr = expandTabs(text, origIndent, tabDist, nullSubsChar, &len); + char *expStr = expandTabs(text, origIndent, tabDist, nullSubsChar, &len); if (!useTabs) { *newLength = len; return expStr; @@ -2475,12 +2380,9 @@ static char *realignTabs(const char *text, int origIndent, int newIndent, */ static char *expandTabs(const char *text, int startIndent, int tabDist, char nullSubsChar, int *newLen) { - char * outStr, *outPtr; - const char *c; - int indent, len, outLen = 0; - /* rehearse the expansion to figure out length for output string */ - indent = startIndent; + int indent = startIndent, len, outLen = 0; + const char *c; for (c = text; *c != '\0'; c++) { if (*c == '\t') { len = Fl_Text_Buffer::character_width(*c, indent, tabDist, nullSubsChar); @@ -2496,8 +2398,8 @@ static char *expandTabs(const char *text, int startIndent, int tabDist, } /* do the expansion */ - outStr = (char *)malloc(outLen + 1); - outPtr = outStr; + char *outStr = (char *)malloc(outLen + 1); + char *outPtr = outStr; indent = startIndent; for (c = text; *c != '\0'; c++) { if (*c == '\t') { @@ -2524,13 +2426,12 @@ static char *expandTabs(const char *text, int startIndent, int tabDist, */ static char *unexpandTabs(char *text, int startIndent, int tabDist, char nullSubsChar, int *newLen) { - char * outStr, *outPtr, *c, expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; - int indent, len; + char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; + char *outStr = (char *)malloc(strlen(text) + 1); + char *outPtr = outStr; + int indent = startIndent, len; - outStr = (char *)malloc(strlen(text) + 1); - outPtr = outStr; - indent = startIndent; - for (c = text; *c != '\0';) { + for (const char *c=text; *c != '\0';) { if (*c == ' ') { len = Fl_Text_Buffer::expand_character('\t', indent, expandedChar, tabDist, nullSubsChar); @@ -2563,10 +2464,10 @@ int while reading data (data was partially loaded). */ Fl_Text_Buffer::insertfile(const char *file, int pos, int buflen) { - FILE *fp; int r; + FILE *fp; if (!(fp = fl_fopen(file, "r"))) return 1; char *buffer = new char[buflen]; - for (; (r = fread(buffer, 1, buflen - 1, fp)) > 0; pos += r) { + for (int r; (r = fread(buffer, 1, buflen - 1, fp)) > 0; pos += r) { buffer[r] = (char)0; insert(pos, buffer); } diff --git a/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx b/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx index abdd2ef1a..5a01f7462 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_Text_Display.cxx @@ -350,7 +350,7 @@ int TextDMaxFontWidth(textDisp *textD, Boolean considerStyles) { } #endif -int Fl_Text_Display::longest_vline() { +int Fl_Text_Display::longest_vline() const { int longest = 0; for (int i = 0; i < mNVisibleLines; i++) longest = max(longest, measure_vline(i)); @@ -798,7 +798,7 @@ void Fl_Text_Display::overstrike(const char* text) { X coordinate where the position would be if it were visible. */ -int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) { +int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) const { int charIndex, lineStartPos, fontHeight, lineLen; int visLineNum, charLen, outIndex, xStep, charStyle; char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; @@ -876,7 +876,7 @@ int Fl_Text_Display::position_to_xy( int pos, int* X, int* Y ) { If continuous wrap mode is on, returns the absolute line number (as opposed to the wrapped line number which is used for scrolling). */ -int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) { +int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) const { int retVal; /* In continuous wrap mode, the absolute (non-wrapped) line count is @@ -904,7 +904,7 @@ int Fl_Text_Display::position_to_linecol( int pos, int* lineNum, int* column ) { /** Return 1 if position (X, Y) is inside of the primary Fl_Text_Selection */ -int Fl_Text_Display::in_selection( int X, int Y ) { +int Fl_Text_Display::in_selection( int X, int Y ) const { int row, column, pos = xy_to_position( X, Y, CHARACTER_POS ); Fl_Text_Buffer *buf = mBuffer; int ok = 0; @@ -933,7 +933,7 @@ int Fl_Text_Display::in_selection( int X, int Y ) { from the last newline. Obviously this is time consuming, because it invloves character re-counting. */ -int Fl_Text_Display::wrapped_column(int row, int column) { +int Fl_Text_Display::wrapped_column(int row, int column) const { int lineStart, dispLineStart; if (!mContinuousWrap || row < 0 || row > mNVisibleLines) @@ -953,7 +953,7 @@ int Fl_Text_Display::wrapped_column(int row, int column) { newlines, rather than display wrapping, and anywhere a rectangular selection needs a row, it needs it in terms of un-wrapped lines. */ -int Fl_Text_Display::wrapped_row(int row) { +int Fl_Text_Display::wrapped_row(int row) const{ if (!mContinuousWrap || row < 0 || row > mNVisibleLines) return row; return buffer()->count_lines(mFirstChar, mLineStarts[row]); @@ -1131,7 +1131,7 @@ int Fl_Text_Display::move_down() { by avoiding the additional step of scanning back to the last newline. */ int Fl_Text_Display::count_lines(int startPos, int endPos, - bool startPosIsLineStart) { + bool startPosIsLineStart) const { int retLines, retPos, retLineStart, retLineEnd; #ifdef DEBUG @@ -1196,7 +1196,7 @@ int Fl_Text_Display::skip_lines(int startPos, int nLines, the start of the next line. This is also consistent with the model used by visLineLength. */ -int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) { +int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) const { int retLines, retPos, retLineStart, retLineEnd; /* If we're not wrapping use more efficien BufEndOfLine */ @@ -1215,7 +1215,7 @@ int Fl_Text_Display::line_end(int pos, bool startPosIsLineStart) { Same as BufStartOfLine, but returns the character after last wrap point rather than the last newline. */ -int Fl_Text_Display::line_start(int pos) { +int Fl_Text_Display::line_start(int pos) const { int retLines, retPos, retLineStart, retLineEnd; /* If we're not wrapping, use the more efficient BufStartOfLine */ @@ -1448,7 +1448,7 @@ void Fl_Text_Display::maintain_absolute_top_line_number(int state) { Returns the absolute (non-wrapped) line number of the first line displayed. Returns 0 if the absolute top line number is not being maintained. */ -int Fl_Text_Display::get_absolute_top_line_number() { +int Fl_Text_Display::get_absolute_top_line_number() const { if (!mContinuousWrap) return mTopLineNum; if (maintaining_absolute_top_line_number()) @@ -1472,7 +1472,7 @@ void Fl_Text_Display::absolute_top_line_number(int oldFirstChar) { Return true if a separate absolute top line number is being maintained (for displaying line numbers or showing in the statistics line). */ -int Fl_Text_Display::maintaining_absolute_top_line_number() { +int Fl_Text_Display::maintaining_absolute_top_line_number() const { return mContinuousWrap && (mLineNumWidth != 0 || mNeedAbsTopLineNum); } @@ -1491,7 +1491,7 @@ void Fl_Text_Display::reset_absolute_top_line_number() { Find the line number of position "pos" relative to the first line of displayed text. Returns 0 if the line is not displayed. */ -int Fl_Text_Display::position_to_line( int pos, int *lineNum ) { +int Fl_Text_Display::position_to_line( int pos, int *lineNum ) const { int i; *lineNum = 0; @@ -1957,7 +1957,7 @@ void Fl_Text_Display::draw_cursor( int X, int Y ) { be more appropriate. */ int Fl_Text_Display::position_style( int lineStartPos, - int lineLen, int lineIndex, int dispIndex ) { + int lineLen, int lineIndex, int dispIndex ) const { Fl_Text_Buffer * buf = mBuffer; Fl_Text_Buffer *styleBuf = mStyleBuffer; int pos, style = 0; @@ -1989,7 +1989,7 @@ int Fl_Text_Display::position_style( int lineStartPos, /** Find the width of a string in the font of a particular style */ -int Fl_Text_Display::string_width( const char *string, int length, int style ) { +int Fl_Text_Display::string_width( const char *string, int length, int style ) const { Fl_Font font; int fsize; @@ -2016,7 +2016,7 @@ int Fl_Text_Display::string_width( const char *string, int length, int style ) { position, and CHARACTER_POS means return the position of the character closest to (X, Y). */ -int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) { +int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) const { int charIndex, lineStart, lineLen, fontHeight; int charWidth, charLen, charStyle, visLineNum, xStep, outIndex; char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; @@ -2082,7 +2082,7 @@ int Fl_Text_Display::xy_to_position( int X, int Y, int posType ) { means translate the position to the nearest character cell. */ void Fl_Text_Display::xy_to_rowcol( int X, int Y, int *row, - int *column, int posType ) { + int *column, int posType ) const { int fontHeight = mMaxsize; int fontWidth = TMPFONTWIDTH; //mFontStruct->max_bounds.width; @@ -2479,7 +2479,7 @@ static int countlines( const char *string ) { /** Return the width in pixels of the displayed line pointed to by "visLineNum" */ -int Fl_Text_Display::measure_vline( int visLineNum ) { +int Fl_Text_Display::measure_vline( int visLineNum ) const { int i, width = 0, len, style, lineLen = vline_length( visLineNum ); int charCount = 0, lineStartPos = mLineStarts[ visLineNum ]; char expandedChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; @@ -2519,7 +2519,7 @@ int Fl_Text_Display::measure_vline( int visLineNum ) { /** Return true if there are lines visible with no corresponding buffer text */ -int Fl_Text_Display::empty_vlines() { +int Fl_Text_Display::empty_vlines() const { return mNVisibleLines > 0 && mLineStarts[ mNVisibleLines - 1 ] == -1; } @@ -2528,7 +2528,7 @@ int Fl_Text_Display::empty_vlines() { Return the length of a line (number of displayable characters) by examining entries in the line starts array rather than by scanning for newlines */ -int Fl_Text_Display::vline_length( int visLineNum ) { +int Fl_Text_Display::vline_length( int visLineNum ) const { int nextLineStart, lineStartPos; if (visLineNum < 0 || visLineNum >= mNVisibleLines) @@ -2794,7 +2794,7 @@ void Fl_Text_Display::measure_deleted_lines(int pos, int nDeleted) { void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, int maxPos, int maxLines, bool startPosIsLineStart, int styleBufOffset, int *retPos, int *retLines, int *retLineStart, int *retLineEnd, - bool countLastLineMissingNewLine) { + bool countLastLineMissingNewLine) const { int lineStart, newLineStart = 0, b, p, colNum, wrapMargin; int maxWidth, i, foundBreak, width; bool countPixels; @@ -2932,7 +2932,7 @@ void Fl_Text_Display::wrapped_line_counter(Fl_Text_Buffer *buf, int startPos, insertion/deletion, though static display and wrapping and resizing should now be solid because they are now used for online help display. */ -int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos) { +int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos) const { int charLen, style; char expChar[ FL_TEXT_MAX_EXP_CHAR_LEN ]; Fl_Text_Buffer *styleBuf = mStyleBuffer; @@ -2963,7 +2963,7 @@ int Fl_Text_Display::measure_proportional_character(char c, int colNum, int pos) the way back to the beginning of the line. */ void Fl_Text_Display::find_line_end(int startPos, bool startPosIsLineStart, - int *lineEnd, int *nextLineStart) { + int *lineEnd, int *nextLineStart) const { int retLines, retLineStart; /* if we're not wrapping use more efficient BufEndOfLine */ @@ -2996,7 +2996,7 @@ void Fl_Text_Display::find_line_end(int startPos, bool startPosIsLineStart, used as a wrap point, and just guesses that it wasn't. So if an exact accounting is necessary, don't use this function. */ -int Fl_Text_Display::wrap_uses_character(int lineEndPos) { +int Fl_Text_Display::wrap_uses_character(int lineEndPos) const { char c; if (!mContinuousWrap || lineEndPos == buffer()->length()) @@ -3011,8 +3011,8 @@ int Fl_Text_Display::wrap_uses_character(int lineEndPos) { Return true if the selection "sel" is rectangular, and touches a buffer position withing "rangeStart" to "rangeEnd" */ -int Fl_Text_Display::range_touches_selection(Fl_Text_Selection *sel, - int rangeStart, int rangeEnd) { +int Fl_Text_Display::range_touches_selection(const Fl_Text_Selection *sel, + int rangeStart, int rangeEnd) const { return sel->selected() && sel->rectangular() && sel->end() >= rangeStart && sel->start() <= rangeEnd; } diff --git a/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx b/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx index ebf0a6645..d0d1b6f45 100644 --- a/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx +++ b/plugins/zynaddsubfx/fltk/src/Fl_arg.cxx @@ -246,7 +246,7 @@ int Fl::arg(int argc, char **argv, int &i) {

  • -geometry WxH+X+Y

    Sets the initial window position and size according - the the standard X geometry string.

  • + to the standard X geometry string.
  • -iconic diff --git a/plugins/zynaddsubfx/fltk/src/fl_color.cxx b/plugins/zynaddsubfx/fltk/src/fl_color.cxx index 94431a440..f611d31ff 100644 --- a/plugins/zynaddsubfx/fltk/src/fl_color.cxx +++ b/plugins/zynaddsubfx/fltk/src/fl_color.cxx @@ -178,7 +178,7 @@ void fl_color(uchar r,uchar g,uchar b) { } //////////////////////////////////////////////////////////////// -// Get a color out of the the fltk colormap. Again for truecolor +// Get a color out of the fltk colormap. Again for truecolor // visuals this is easy. For colormap this actually tries to allocate // an X color, and does a least-squares match to find the closest // color if X cannot allocate that color. diff --git a/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx b/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx index d28788fd5..15dce417c 100644 --- a/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx +++ b/plugins/zynaddsubfx/fltk/src/fl_draw_image_win32.cxx @@ -153,7 +153,7 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, bmi.bmiColors[i].rgbBlue = (uchar)i; bmi.bmiColors[i].rgbGreen = (uchar)i; bmi.bmiColors[i].rgbRed = (uchar)i; - bmi.bmiColors[i].rgbReserved = (uchar)i; + bmi.bmiColors[i].rgbReserved = (uchar)0; // must be zero } } bmi.bmiHeader.biWidth = w; @@ -164,6 +164,10 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, bmi.bmiHeader.biBitCount = depth*8; int pixelsize = depth; #endif + if (depth==2) { // special case: gray with alpha + bmi.bmiHeader.biBitCount = 32; + pixelsize = 4; + } int linesize = (pixelsize*w+3)&~3; static U32* buffer; @@ -218,9 +222,13 @@ static void innards(const uchar *buf, int X, int Y, int W, int H, for (i=w; i--; from += delta) *to++ = *from; break; case 2: - for (i=w; i--; from += delta) { - *to++ = *from; - *to++ = *from; + for (i=w; i--; from += delta, to += 4) { + uchar a = from[1]; + uchar gray = (from[0]*a)>>8; + to[0] = gray; + to[1] = gray; + to[2] = gray; + to[3] = a; } break; case 3: diff --git a/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx b/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx index 13248a9fa..f2f400d8a 100644 --- a/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx +++ b/plugins/zynaddsubfx/fltk/src/fl_shortcut.cxx @@ -305,6 +305,10 @@ char Fl_Widget::label_shortcut(const char *t) { } int Fl_Widget::test_shortcut(const char *t) { + #ifdef WIN32 + // on MSWindows, users expect shortcuts to work only when the Alt modifier is pressed + if (Fl::event_state(FL_ALT)==0) return 0; + #endif char c = Fl::event_text()[0]; if (!c || !t) return 0; if (c == label_shortcut(t)) diff --git a/plugins/zynaddsubfx/fltk/src/fl_utf.c b/plugins/zynaddsubfx/fltk/src/fl_utf.c index f50859fd8..1362ef755 100644 --- a/plugins/zynaddsubfx/fltk/src/fl_utf.c +++ b/plugins/zynaddsubfx/fltk/src/fl_utf.c @@ -105,7 +105,7 @@ static unsigned short cp1252[32] = { /*! Decode a single UTF-8 encoded character starting at \e p. The resulting Unicode value (in the range 0-0x10ffff) is returned, - and \e len is set the the number of bytes in the UTF-8 encoding + and \e len is set to the number of bytes in the UTF-8 encoding (adding \e len to \e p will point at the next character). If \p p points at an illegal UTF-8 encoding, including one that