UITextView, with spell checking, how to use `ignoreWord`? - ios

Regarding the spell checking in iOS, it's possible to tell the checker to ignore a word (or learn a word),
https://developer.apple.com/documentation/uikit/uitextchecker
func ignoreWord(String)
Tells the receiver to ignore the specified word when spell-checking.
- Apple doco
Say I have a UITextView which opens. I want spell checking On.
I know the user may type "fattie" which would get the red underline.
How do I tell that text view in that instance, to, ignore "fattie" ?
An obvious use case ...
User is typing in "#tag" type friends; in our data of course we know what all the tags are, it's absurd they get marked as spelling errors.
It seems incredible one can't just say "don't underline these words - - list".
Code example ....
So we have
var t: UITextView
and then, there must be "some way" to:
yourTextView.something->something.textChecker.ignoreWord("fattie"
.. some way to get to the text view's textChecker instance! How ?!?!

Partial answer: I just stumbled on to that, bizarrely, you can just call
UITextChecker.learnWord("fattie")
UITextChecker.learnWord("blahdee")
from, apparently, just anywhere in an app.
However this raises many issues,
• How to call the 'ignore' one, which seems better
• That one still makes the user tap the annoying, stupid, "in quotes" OK box in the suggestions bar - it seems to have not really "learned" anything
• Disturbingly, I think this goes for the "WHOLE PHONE". I only want it in that instance of the user using that text view.
A mystery!

Related

How to use bell character (BEL, CTRL-G, \x07) with xterm.js?

How do I add use the bell character with Xterm.js? I see a couple of entries in the sources 'options' defaults, but dont get anything whether i send it from the shell or write it directly to the terminal, even with those set to true. I tried overloading the term.bell function with one containing a window.navigator.vibrate, and that works if I call it directly, but doesnt fire in response to a bell character.
Ok. So testing determined nothing is blocking the bell character ("\x07" or "\u0007") from getting through to xterm.js. It just doesnt respond, even if you enable the flags in the options. The code in the source looks like it should work, but something internal is not connected. Since I am avoiding actual changes to the source to make upgrades to xterm.js straightforward and out of the box, I worked a little magic. Here's a hack to get the bell character working:
Make a function that fires on the "message" event from your websocket. In it, check for a match for BEL. Then have it do your voodoo if it detects it. Something like:
sock.addEventListener('message',function(v){ if(v.match(/\x07/)){ /*voodoo here*/ } });
Where v is event, \x07 is BEL, and voodoo is code or an invocation to blip the screen white briefly, make a chirp, vibrate if your getting around on "mobile", or open a portal to the single-sock dimension.
Annoyingly, now I need to look up more ansi codes and find a pattern, as some end in a BEL character. So this will work by itself, but will be set off by some codes not intended to act as BEL, because they contain that character. More on this later....
FYI, not sure if this works with term.attach(). I have my own thing that does some preprocessing anyway, so basically all I had to do was splice in the if/match, but cut that out, the above code is the minimal cut-paste version.
Hope this helps someone else. Bug out.

How to copy class and function name in Blackfire report

When I am copy-pasting method name from Blackfire profile, I am getting a reversed string like this:
sgnitsiLredivorPdaol::yrotisopeRresopmoC\yrotisopeR\resopmoC
What is intended way to copy a proper method name (not reversed)?
Why does Blackfire has such behaviour? Is this some kind of stupid joke or copy-paste protection?
This is indeed a UX issue we currently have in Blackfire, let me explain it to you:
We want to display the end of the namespace/classname value in this part of the interface
We want to have a text-overflow ellipsis on the left part of the value.
Unfortunately, using text-overflow: ellipsis on the left of the text is not supported by modern browsers at the moment.
There are two ways to do that: Either know the width of the text, work with a fixed width column and truncate programmatically or use a hack, revert the letters, change the text direction from left-to-right to right-to-left locally and use traditional text-overflow.
As we deal with a resizable UI here, we chose the second option, and this is the one that provide the better experience at the moment. However, as you notice, this issue remains.
We're thinking about a fix for this issue. It might be with the Clipboard API.
In the meantime, here's the way you can copy/paste the value :
Just expand a node and copy from the inner box, see:
Hope it helps you until we find a better solution.

Alter Xcode 7 autofill behaviors

With the latest build, or maybe including the builds prior to beta 7.5 I just never noticed, I'm getting annoyed with a little autofill feature Apple implemented for substitute tokens and their objects when creating log messages. I haven't really noticed this with class methods or instance methods or autocompleting anything else really, so far.
Before, in Xcode 6, this would display:
Ahhhhh, nice & crisp. As you can see, everything suffixing the user input is opportunity for autofill. All I had to do was press tab[enter] once to autofill 'error' and include the closing parenthesis, then it would automatically place my cursor after the closing parenthesis, hence ALL I had to do was type a ; for that statement to be complete and I was happy :)
Now, this displays :
Ehhhhh, troublesome & redundant. As you can see in this example, it includes an additional quotation mark. Now when I press tab to autofill 'error', it just autofills 'error' and places the cursor before the closing parenthesis. So it looks like this:
NSLog(#"%#", error|)
And if I were to press tab to go to the next sub word that needs autocomplete it will just indent the closing parenthesis:
NSLog(#"%#", error )
So essentially, I have to either move it with my mouse or press → and then and only then, I'll be able to enter a ;. Side note - pressing ↵ to autofill results in the same behavior as described.
I am a fast typer, don't want to say my speed because I don't want it to rub off the wrong way but it's 70+wpm, so this irritates me, especially since I've been used to a way for so long. Any way to correct the behavior?
I have tried turning off Enable type-over completions in the Xcode preferences pane, but it still places the cursor before the closing parenthesis.
printf resorts to the same behavior with Xcode 7.5

iOS Custom Keyboard, Suggestions from txt file

I'm making a custom keyboard for lawyers, and trying to load law related words in suggestion/prediction bar on top the keyboard based on what user types. Just like in stock keyboard. I have searched around but did not find any concrete answer.
I want to display suggestions of law related terms that I have in a txt file, all words are sorted alphabetically.
DEMO
Here is what I have tried:
UILexicon
let myLexicon = NSMutableDictionary()
self.requestSupplementaryLexiconWithCompletion { (theLexicon: UILexicon!) -> Void in
let lexiconEntries = theLexicon.entries
// Completion handler
for item in lexiconEntries {
self.myLexicon.setObject(item.documentText, forKey: item.userInput)
}
}
This code just gives 23 nil objects.
UITextChecker This is an iOS class that is designed to spot spelling errors, which makes it perfect for knowing if a given word is real or not. This is seems to be mainly for autocorrection, not for suggestion. Correct me if I'm wrong please.
I cannot somehow make sense out of these two classes.
How do I tell custom keyboard, "Hey if user enters "V" show the top 3 words that start from V, then if user enter a, fill the suggestion bar with words that start with "Va" and so on.
EDIT: Looks like someone ran into same problem. Here is a quote how they solved it, I will update with code once I finish figuring this out myself.
However, this was far from the truth - in fact, Apple do not allow access to their dictionary full stop, only offering a UILexicon class instead as stated in their docs:
Make use of this class, along with a lexicon of your own design, to provide suggestions and autocorrections as users are entering text.
As it turns out, the UILexicon class only really contains contact names along with any shortcuts (like the default On My Way!) defined on the device. So before writing the logic for a keyboard, you first have to implement your own autocorrect library.
We browsed through a few external projects to see if we could include them in the keyboard - most notably Hunspell, which is used by OpenOffice, and Presage, an intelligent predictive text library.
I spent a long time integrating the C++ libraries with the code, but in the end, in order to keep complexity down, we opted to use a combination of UITextChecker (which provides some basic corrections) and our own custom dictionary, containing a few commonly mispelled words.
Link to the Article
Thanks!
You have to implement your own autocorrection system. UILexicon will only give you shortcuts the user has set up, words that they have added to the iOS Dictionary, and names of contacts. It has no awareness of any words that you yourself provide, whether in a txt file or in any other form.
If you want to use the TOMSSuggestionBar, it appears from the sample code that the onus is on you to convert your txt file into a core data model, and indicate to the suggestion bar how it is to interpret the contents of that model. You may also want to implement the data source protocol to get more fine grained control over the suggestions.
Autocorrection and next word prediction are not solved problems; I suggest you do your own research and find the solution that is best suited to your goals.

special character coming when i am using & and p

I dont know what exactly i have to type in title for this ,i tried my best
anyway coming to topic
I am making one acc checker for that purpose ,i am sending user and pass from my bsskinedit1 and bsskinedit2
here is my code
s:='http:\\site.com..premlogin='+bsskinedit.text+'&password='+bsskinedit2.text
but it giving some error ,then i used showmessage whats wrong with it then i came with strange result
see below
observer after 4 & and p combining together and appearing as a some new symbol :(
can any one tell me why its coming like this ?
Your code (where you build the URL) is most likely correct (I guess the above has some typos?!), but when you display the URL in a label for instance, the & character is treated as indicator for an accelerator key.
By Windows design, accelerator keys
enable the user to access a menu
command from the keyboard by pressing
Alt along the appropriate letter,
indicated in your code by the
preceding ampersand (&). The character
after the and sign (&) appears
underlined in the menu.
If you want to display the & character itself, you have to set your string variable to &&.
By placing two ampesands together - you state that the character following the first one is not used as the accelerator - rather you actually want to get it (only one) displayed.
Just use your debugger if you want to see the real value that your string variables have, don't output them to a message box or the like... It may have side effects, as you can see.
Regarding the URL you build: I can't possibly know how it has to be correctly, but at least you should use the right slashes!
s := 'http://site.com...'
(All quotes from delphi.about.com)
In addition to what Mef said, you can use OutputDebugString to add your string to the event log in its raw form, so you don't need to modify it before displaying it. Delphi should capture those strings automatically if you're running from the debugger. If you aren't running it from Delphi you can use DebugView instead, which captures the messages from any running applications.

Resources