I am running netbeans 8.1 and scene builder 2.0 with javaFX 8.0. I have just started messing around with the TextFlow container recently. In my program, I have wrapped a textArea inside the TextFlow container, but I cannot figure out how to use my textflow to count the number of lines being displayed inside the text area. Some people recommend using "flowcomposer", but I do not seem to have the flow composer option for some reason, and I'm not really sure how to import it...
Text wrapping is set to "true" inside my textarea...unfortunately, this means I cannot programmatically count lines "as-is" by counting the number of newlines, since wrapped text does not include a newline character.
Ultimately, not only do I want to be able to get the number of lines being displayed, but I also want to get the current line or position my cursor at a specific line/scroll to a specific line.
What do you guys think? Is textflow and flowcomposer the way to do this, or am I barking up the wrong tree? If this is indeed a viable way to accomplish the goals stated above, why am I not being able to use textflow to get the lines?
Any help would be greatly appreciated!:)
Related
I want to add a line counter to a textfield for a sort of text editor. Looking around, I've seen that a lot of questions on this topic are either unanswered, or do not answer in a satisfactory manner. Something like this How to add prefix widget on every new line in textfield in flutter? asks fundamentally the same question I am, however the only answer there is to create a new widget for each line.
This is one method that could be used, where I add new textfields in a list and build them in a row with their respective line number. However, this means I cannot have those textfields function on more than one line, and I will need to add more textfields each time a user wants to add enough text to make it overflow. The biggest flaw I see with this, though, is that it makes it harder (if not impossible?) to easily select and edit text as you would expect from a text editor, such as using the built in systems for a textfield.
Now, for my solution I am using https://pub.dev/packages/extended_text_field as a way to gain some functionality that I don't really want to take the time to figure out how to do on my own (embedded onClick callbacks for text), so it would be ideal if I could continue to use that without having to fork or even have to figure out how to write my own version.
The primary issue I'm running into is not necessarily getting the number of lines, which can be found using some solutions from How can I add line numbers to TextField on Flutter?, but rather how and where to show those line numbers.
As above, it's not really ideal to pair some number alongside a textfield and create a new textfield for each expected line. What would be ideal, however, is something like , where each line number is prefixed to the line built by the text field. For example, like this: . Something like the solution proposed in Add a prefix to every line in a multiline Text Input in Flutter? would not work especially well, because the solution there is to literally add string values to the textfield, which would require systems to clean the text, in addition to causing an unexpected ability to actually change the numbers (or other line prefix) by the user.
So -- is there any way to implement a line prefix for each line in a textfield? Would it be possible to override an InputDecoration (which allows creating the individual line prefix, but nothing more) to create a line prefix for each line drawn by the textfield? If not, exactly what would be needed to create this? I am familiar with flutter, but I am not quite as familiar with the lower level API's.
When i click "Format Document" button inside of page, it looks like this,
From what I can tell, you are trying to solve the awkward line wrapping and deep nesting problem. When your code gets nested as deep as it is, it hits the column word wrap limit and the limit forces forces the formatter to break items that would normally be on one line into several. There are a couple things you can do:
Best option: Refactor your code and split it into multiple classes/ files. That will make it so that you don't have as deeply nested code and it will make it more readable as well as more maintainable.
Go to the vs code settings and search for Dart: Line Length and edit the value to set when the file starts wrapping content.
I've been working with large print statements in VS Code recently and was wondering: is there was an easy way to turn on word wrapping in the OUTPUT window rather than having to use a horizontal scroll bar?
In a situation where I'm printing a string with hundreds of characters, I would like it to be able to wrap around the output window properly.
There is an editor word wrap setting but I have not been able to find anything that actually affects the output window.
I am trying to build a Perl TK text widget that supports line folding (similar to Visual Studio folding capabilities).
Is there an existing one already? (tried googling it, and searching CPAN, didn't find any)
Is there a way to make few lines disappear in the Tk::Text widget? (so i can write the logic behind the folding routines...)
Eliding Text
You can actually include text in the widget that is not displayed; this is known as "elided" text, and is made available using the "elide" configuration option for tags. You can use this to implement for example an outliner, a "folding" code editor, or even just to bury some extra meta-data intermixed with your text. When specifying positioning with elided text you have to be a bit more careful, and so commands that deal with positions have extra options to either include or ignore the elided text.
Giving Thanks to the references
I have text files which contain code inside an Editor. The user can run an analysis on a certain part of his code, which will result in a set of lines which should be hidden. Next I want to present the user with only the remaining lines, but with correct linenumbers, as from the original document. Possible solutions I thought of:
Open a new Editor which does not contain the hidden lines, but *somehow* still has correct line numbers
Hide the lines in the original editor, and offer a button for the user to 'unhide'. Probably a similar solution required as in 1.
I don't really know how to go about this. Folds would be a weird solution, because they can be unfolded individually, and seem to be more semantically tied to things like methods or classes. Also, simply creating a new document without the hidden lines results in wrong linenumbers.
Use a ProjectionViewer and reflection to invoke the private method ProjectionViewer.collapse(int offset int length). This method is only used internally to hide a certain portion of the text, by manipulating the ProjectionDocument (see http://eclipse.org/articles/Article-Folding-in-Eclipse-Text-Editors/folding.html).
After this, folding text in the editor using the annotations(the little +/- icons) WILL break everything, so this solution and regular folding are mutually exclusive.