UFO: Alien Invasion Issue Tracker
UFO: Alien Invasion
Go to the previous open issue
Go to the previous issue (open or closed)
star_faded.png
Please log in to bookmark issues
icon_project.png UFO: Alien Invasion / Closed Submit Patch #5111 [RFC][PATCH] * Allow cursor movement within text entry boxes
Go to the next issue (open or closed)
Go to the next open issue
This issue has been closed with status "Closed" and resolution "RESOLVED".
Issue basics
  • Type of issue
    Submit Patch
  • Category
    Not determined
  • Targetted for
    2.5
  • Status
    Closed
  • Progress
  • Priority
    Not determined
User pain
  • Type of bug
    Not triaged
  • Likelihood
    Not triaged
  • Effect
    Not triaged
Affected by this issue (0)
There are no items
People involved
Times and dates
Issue details
  • Resolution
    RESOLVED
Attachments (6)
Duplicate issues (0)
This issue does not have any duplicates
Description
'''This is a request for comments on this patch. I'd appreciate a review of this code; if any issues are found, I'll gladly fix them and submit a new revision below.'''


Before now, in a text entry box, editing could only occur at the end of the text string. With this patch, one can move the cursor around inside of text entry boxes using the keyboard. Now the middle of a text string can be edited, as well. Left/right arrows, backspace, delete, home, and end keys work as expected.


'''Concerns/Possible improvements''':
* Where to put the cursorPosition variable -- into an existing struct, or global? It seemed to fit well next to the global isAborted variable.
* Because the UTF-8 editing functions ''UTF8_insert_char()'' and ''UTF8_delete_char()'' work with byte offsets instead of UTF-8 character offsets, I had to create a new function, "UTF8_char_offset_to_byte_offset" to convert from one to the other.
* Would it make more sense for the UTF-8 functions to be edited to use UTF-8 character offsets instead of byte offsets? ''UTF8_insert_char()'' and ''UTF8_delete_char()'' are ONLY used for text entry boxes, so can be changed quickly and easily.
* Possible future improvement: when text is larger than the text entry box, always scroll to the text at the cursor.
* Possible future improvement: cursor can disappear when text uses about 62 bytes. Due to preexisting off-by-one bug in UTF8_insert_char(), fortunately in the overly-cautious direction.
* Possible future improvement: text only displays about the first 62 bytes before cutting off. Due to preexisting mismatch between cvar size and buffer size for display.
* Possible future improvement: graphical cursor instead of a text character cursor.
* Possible future improvement: add ability to select cursor position using mouse.


(Additional keywords for future searches: textboxes, text editing boxes, "edition".)
Todos (0 / 0)
Issue created
footer_logo.png The Bug Genie 4.3.1 | Support | Feedback spinning_16.gif