getting all the misspelled words in gtktextview while using gtkspell - gtk

How can i get all the texts which are misspelled on gtktextview
so that i can put those on container and use for future actions.

You can't do that directly in GtkSpell. You could try searching the text buffer for any text with a tag that has its "underline" property set to PANGO_UNDERLINE_ERROR.

Related

TextMeshPro Input field - can't set placeholders' wrapping to enabled?

I am trying to have a TMP Input Field with multiline (wrapped) placeholder. The input field has its content type set to Integer Number. Placeholder text has some string as text and has wrapping set to "enabled". In prefab editor, it looks ok (text is wrapped). However, when the scene loads, placeholder text immediately has its wrapping reset to "disabled".
The problem: I assume Input field resets the wrapping to disabled on child text, because its content is not multiline, as specified here. I can't set the input field to accept multiline - the option is not in inspector; I can see it if I switch to Debug mode, but as soon as I set it to multiline it switches back to single line. So, how do I set the wrapping on placeholder to enabled without it getting switched back to disabled in runtime? Or, alternatively, how do I set my InputFiled to be multiline (I assume that will fix the wrapping on the placeholder)?
What I have for now:
I have an input field that works like this: when it's not focused, there is a multiline text, for example: "Write your\nnumber here!". When focused, it's replaced by empty line and user can enter an integer number. On finishing input (OnEndEdit) I use the input to spawn some GameObjects and then replace the text again with "Write your\nnumber here!". Editor screenshot:
Right now it works as I expect. However, now I want to dynamically change the placeholder text, so I don't know where the newline will be and I would like for TMP to wrap the text for me, same as it does in Text component with Wrapping enabled.
So: how do I use TMP's wrapping - enabled on InputField without it getting reset to disabled? Either both the user input and placeholder, or just on placeholder itself - doesn't matter.
MultiLine is only available if the Content Type is set to Standard or Auto Corrected.
As soon as you set the input type to Integer Number it basically behaves just like an integer field in the Unity Inspector: No line wrapping but rather overfloating and scrolling to the right.
Alternatively if you need multi lines you could set the Content Type to Custom and then fully flexible adjust it to your needs like e.g.
LineType : Multi Line Newline
Line Limit: 0
Input Type: Standard
Keyboard Type: Default
Character Validation: Integer
And in general: Of course you also can't set a text to an input field that only accepts integer numbers ;) Rather set your placeholder text in the Placeholder object!
Anything that is applied to the Placeholder will be displayed automatically as long as there is no value typed in the input field!

New line on UILabel messes with the word wrapping [duplicate]

Under certain circumstances, UILabel seems to bring an extra word to new line even when there is enough space for it, for example,
If one more word is appended,
Even if I force the width of the label to become something like below, it still moves the word consists of "c"s to the next line,
I've tried twisting the configuration of the UILabel, but seems it behaves the same unless I set the line breaking mode to character wrap, below is the configuration for the above cases,
And the constraints (in the first two cases, the trailing ),
Is there any reason for this particular behaviour and can I fix this? It looks weird in this way leaving that space emptied.
this is the default behavior since iOS 11, to fix orphaned words. No way to shut it off
to fix it
use the text as attributed text
or
use UItextview and turn of the scroll, edit option
or
use the custom label here
Get each line of text in a UILabel
You should set the line break to character wrap, because the letters after the space will be recognized as a word.
Hey I know this is late but I just figured out that you can cheat the system by adding a bunch of spaces at the end of the text.
If text of UILable may be changed, then it's still possible to use quick-dirty hack with "\n" - new line symbol.
Text "Aaaaaaaaaaaaaa bbb cccccccccc\ndddddd" will force UILabel to display:
Aaaaaaaaaaaaaa bbb cccccccccc
ddddddd
In Interface Builder new line can be inputted with Ctrl + Enter
If u use wordWrap, it tries to keep words in full form, as a result of this, it goes to next line. If you use character wrap, it will break on characters, and push the chars onto next line.
For Example:-
My name is ABCXXXX and I (have space here)
love myself.
Solution:-
Use NSMutableAttributedText and write love\n. It will make the "love" be in the space myself in the next line.

Get current Highlight in VS Code Extension

I am not talking about the current selection, which can be accessed by vscode.window.activeTextEditor.selection.
When the cursor is inside an identifier, variable name, etc, it becomes highlighted, as shown in this screenshot:
What is this highlight object called? How do I access it?
Searching for everything from "highlight" to "identifier" and whatever else, the answer was more obvious. TextDocument has a getWordRangeAtPosition method, which takes a position and returns the range of the word.
const editor = vscode.window.activeTextEditor;
let cursorPosition = editor.selection.start;
let wordRange = editor.document.getWordRangeAtPosition(cursorPosition);
let highlight = editor.document.getText(wordRange);
// highlight will now contain the currently highlighted word
The thing you are showing is called a Document Highlight. Other instances (of in this case colorData) will also be highlighted. The answer by #Rene Roth is probably answering what you want. And as #Gama11 wrote, using getWordRangeAtPosition without a second parameter uses the "word pattern" of a language. However a document highlight doesn't have to be a single word.
As far as I know you can't get a list of all the highlights? (I've only just figured them out for use in my first extension.)
To highlight like that you need to use registerDocumentHighlightProvider and provideDocumentHighlights. The DocumentHighlightKind can be used to provide different highlight colors (say when an instance of a highlighted variable is on the right or left of an equal sign, i.e. read or written, or for some other reason for distinction). I've used DocumentHighlightKind successfully to show a highlight that's contained within another.

Deselect text programmatically

I am using a Text widget.
I have over-ridden the right click to display a popup menu in my Perl/Tk GUI. But whenever I right click at any position, the text from the earlier cursor location till the location where I have right clicked gets highlighted.
I don't know what is causing this, so I simply want to programmatically deselect this highlighted text.
How do I go about doing this?
Thanks!
EDIT:
I have made a bind for right-click and this is the subroutine that is called:
sub rightClickMenu {
my ($self, $x, $y) = #_;
$txt->tagRemove('sel', '1.0', 'end');
$rightMenu -> post($x, $y);
$txt->tagRemove('sel', '1.0', 'end');
}
I have removed the sel tag twice (just to be sure). $rightMenu is the menu that is popped up. It shows perfectly fine when right-clicked.
The selection in the text widget is handled by setting the tag sel for the selected range of characters. This tag can be removed like this:
.t tag remove sel 1.0 end
assuming the pathname of your text widget is .t. This specifies that for all characters from the first (1.0) to the character position after the last character (end) the tag sel is to be removed.
Note: normally when removing a tag one has to deal with the possibility that it has been assigned to multiple ranges in the text. The tag removal invocation above clears the tag from the whole text, and that's fine for the selection tag since you're (usually) only supposed to have one selected range anyway. If there are multiple ranges that have the tag foo and you want to clear just one of them, you first need to find the starting and ending indices of that range and clear (by calling tag remove) the tag only between those.
Note 2: All this is assuming that the visible effect is actually caused by the sel tag getting set. In Tk, it's not a standard binding for button 2 to set this tag: it could be that some non-standard binding in Perl-Tk sets some other tag that is displayed visually in the same way as the sel tag is. For further investigation, this command may be useful:
.t tag names $placeWhereIRightClicked
(again assuming the pathname of your text widget is .t, and that placeWhereIRightClicked holds the index of the place where the right clicking occurred) will tell you all tags that are active at that index.
(The command
.t tag names
will list tags for the whole text.)
TkDocs has an article about the text widget where the tag remove command is mentioned, but how to do it in Perl-Tk isn't showed.
The CPAN documentation for the text widget says that the syntax for the command is
$text->tagRemove(tagName, index1, ?index2, index1, index2, ...?)
so I suppose
$text->tagRemove('sel', '1.0', 'end')
or something like that is the way to do it (no Perl, can't test).
(Note: the 'Hoodiecrow' mentioned in the comments is me, I used that nick earlier.)

Use of UISearchBar with NSAttributedStrings for Highlith the search text

Hi Can any one help me how i can use NSAttributedStrings with UISearchBar. actually i want to search text from array or database and then want to highlight the matching keyword, How i can highlight the matching keyword? Please Help me ?
Use Custom Cell with OHAttributedLabel in it for display of Highlighted search text according to result