Text object: operators to move cursor to the top or bottom #106196
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#106196
Loading…
Reference in New Issue
No description provided.
Delete Branch "pioverfour/blender:dp_font_move_home_end"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The FONT_OT_move and FONT_OT_move_select operators had most of the
usual operations (char, line, block, page), but the option to go to
the top or bottom of the "file" were lacking, whereas they had been
implemented in the text editor.
I found these shortcuts lacking while editing many text objects in a
scene, as these operations are ubiquitous in text editors.
This commit adds the options using the rather standard Ctrl + Home and
Ctrl + End shortcuts to move. The same shortcuts select by using Shift
as well.
Both the Blender default and Industry compatible keymaps have been updated.
Font: add options to move the cursor to the top or bottomto Text object: operators to move cursor to the top or bottomSeems like a good feature.
Hey, that's pretty cool!
I think you'd want to handle this as new cursmove types - added to the defines at about line 37 of DNA_vfont_types.h. That way the define FO_CURS_IS_MOTION can use these correctly. Although not obvious, I think FO_CURS is meant for changes that keep the cursor on the same line and the code is treating moves that change the cursor's vertical position specially. The comment at the use of
FO_CURS_IS_MOTION
is "apply vertical cursor motion to position immediately otherwise the selection will lag behind".The other thing is I'd think of a replacement for "file". "paragraph" seems to fit with other uses there.
It looks like it, but what I don’t understand is that the new modes I introduced don’t suffer from this lag, which do happen to the other modes when commenting the block you mentioned. So I can certainly add
FO_TOP
andFO_BOTTOM
types in DNA_vfont_types.h, but then I don’t know how to modifyvfont_to_curve()
accordingly, since selection looks to be working already.I used
FILE
because that is what was used in the text editor, but I agree it doesn’t really work here. However, to me “paragraph” would mean the next or previous new line character. How about simplyTEXT_BEGIN
andTEXT_END
?I noticed the same thing. I tried to see the lag with your patch but could not. So I just assumed I was testing inadequitely. Which is a pretty good assumption; I wouldn't remove or ignore that comment until I was very certain that I knew circumstances had changed since it was written.
Sounds great!
Fairly certain this is all you need:
FontBeginEnd2.diff
Ok, thanks. That’s about what I had started to do, but since it didn’t add much in
vfont_to_curve()
I thought I was doing it wrong.Text object: operators to move cursor to the top or bottomto WIP: Text object: operators to move cursor to the top or bottom72fb31f736
to79104a7e0a
WIP: Text object: operators to move cursor to the top or bottomto Text object: operators to move cursor to the top or bottomJust in case you are not aware, your PR as it is right now is missing the addition of
TEXT_BEGIN
&TEXT_END
to the enun in curve_intern.h at about line 45, so it won't compile. It was in my version of the diff I attached earlier so you might have just missed that one bit.While looking at it I also thought I'd look at the only part (of my code LOL) that bothered me. In vfont.c in that huge and ugly vfont_to_curve function we are using a local variable called "lnr". Our changed code is assigning a new current line number to that variable. But we enter that section of code with that var set to the last line number, which results in that awkward "pass" for FO_TEXTEND.
The following is the same as my prior but with an earlier assignment of the value of "lnr" to a "last_line" variable that is used instead. That way FO_TEXTEND can have a more logical "lnr = last_line".
106196c.diff
Indeed, I didn’t stage everything when I applied your patch. Sorry about that…
The newer change seems all right, but what I don’t quite get is that
last_line
is already declared as anint
earlier in the function. Won’t redeclaring it with a new type ofconst int
risk being confusing or even breaking?79104a7e0a
toab772cc711
No worries!
Yikes, didn't notice that other
last_line
and that does indeed make it confusing. It works because it is in a different scope - anything declared inside of that "if (ELEM(mode, FO_CURSUP, FO_CURSDOWN..." will be local to that section within the curly brackets.Unfortunately that global "last_line" doesn't hold what we need; it is just "-1" at that point, so we can't use it for that purpose. But feel free to rename it or do anything that makes sense. I just found my earlier revision with the
FO_TEXTEND
"pass" to look weird. But you can always put that back if it looked okay to you.Thanks for the explanation, that’s what I had gathered but since that function is a bit of a mastodon I wasn’t sure I was following.
I spent quite a while examining the code, and I’m not sure any more that new
cursmove
modes are needed at all, based on these observations:BKE_vfont_to_curve()
;PREV_WORD
,NEXT_WORD
,PREV_CHAR
, andNEXT_CHAR
modes may change the line number too if they are at the first or last char in the line, yet they don’t use specificcursmove
modes. All they do is calculate a new value foref->pos
and the selection still works fine.I’m not entirely sure of this, but my intuition is that the point of letting
vfont_to_curve()
calculate the newef->pos
is that it is much more complex when going to another line, say forNEXT_LINE
, because the position of each char first needs to be computed from the beginning of the text, depending on their width, kerning, box sizes, etc., to know which char the cursor will fall on.In the case of the text beginning or end though, it’s trivial: 0 or ef->len.
So I’m honestly tempted to revert to the first commit, simply using
TEXT_BEGIN
instead of my first choiceFILE_TOP
.Let me know what you think!
Hey, I'm happy as long as it reads well, makes sense, and gets tested well. Your original was fine, I think I just make it more complex for you because of that warning comment. But if you can go back to the simpler version and it works and selects well then that is great.
ab772cc711
toa8848a1c7e
Cool, I reverted now, and couldn’t find anything wrong with the cursor behaviour—except for an issue which had been there since at least 2.79, but that’s a different story.
Yes, is a nice addition to the feature set.