I have a Processing code which displays words from a text file. I have created a right click function which erases words from the screen if they are not wanted, so that next time the code is run, those words should not be seen. I created another file containing all the delimiters/words that are not required. How do I add the unwanted words to this file, on the right click? I hope my question is clear. Thanks a lot for all help!
When you start the application, I imagine you also load the delimiters/unwanted words text file and add those to a String[]. When there's another right click, you append that right clicked word to the loaded String[] of unwanted words and then decide when you want to save the file(overwrite the previous definitions) - with a save button, using a timer, etc.
Here's a quick snippet to illustrate the idea:
String[] unwantedWords;//array of words to be loaded from an external text file
void loadUnwantedWords(){
unwantedWords = loadStrings("unwanted.txt");//load words from text file
}
void saveUnwantedWords(){
saveStrings("unwanted.txt",unwantedWords);//save words to text file
}
void addUnwantedWord(String word){//call this on your right click event
unwantedWords = append(unwantedWords,word);//append a new value to the existing unwanted words array
}
Note that normally and Array has a fixed size, but Processing's append() function allows you to add new values to an existing array. Once you're array is updated, all you need to do is save it back to the text file, so the new definitions will be there when you restart the application
Related
using the "Replace..." [Find menu] function a slide-in at the bottom appears with an option field/entry for "Find:" and below that one, one for "Replace:"
having completed a replace [eg "Find: abc", "Replace: xyz"] for instance by employing "Replace All" the very slide-in disappears
now for another, new, search, for instance within a document having selected a different, let's say word like "oha", that selection 'oha' is auto-copied over as new entry in "Find:" when using "Replace..." again. this is to say that now in "Find:" the entry does read "oha" tho didn't paste it manually in -- the "abc" entry fromthe previous search got replaced
however, the last entry in the "Replace:"-entry-field remains unchanged
it's the "Find:" entry that get's auto filled in w/out the option [as far as i could figure out]
and that exactly is my question about :
any option to modify Sublime's settings such that nothing gets changed/auto-copied/filled-in at "Find:" ?
pretty annoying behaviour, as i experience it, for instance when having to replace just a single character combi within similar text and each time the copy-selected text get's auto-copied/filled-in at "Find:" rather than leave it be till the usr opts to modify that entry from previous replace-calls
The Find and Find and Replace widgets automatically populate the Find box with either the current selection if there is one, or the previous value used in that box. This box is a dropdown, which contains the previous values used, so you can easily go back through your history in that window and not have to re-type a complicated regular expression, for example.
When the Find box opens pre-populated with a value, it is automatically selected, so to get rid of it all you have to do is hit Backspace or Delete. Alternatively, you can just begin typing your new search query, and it will erase the old one.
There is a setting in Sublime Text 4 that modifies this behavior:
// If true, the selected text will be copied into the find panel when it's
// shown.
// On Mac, this value is overridden in the platform specific settings.
"find_selected_text": true,
If you set "find_selected_text": false, in your user settings, you can disable this behavior.
I have a basic Mac app with a stock NSTextView ("Rich Document Content Text View" in Interface Builder), but I have also observed this behavior in TextEdit:
Create a new bulleted list with 3 items
Select and copy a single list item
Paste the list item into the same document
→ The pasted item loses its list formatting, i.e. when I press Return at the end, no new list item is automatically added.
→ When I select two or more list items, it works correctly.
Here's a quick video:
Other observations
I tested the same procedure in Scrivener (which I believe also uses NSTextView), and here copying a single list item places the correct formatting list attributes on the clipboard.
I inspected the clipboard and when I copy a single list item, indeed, the RTF contents are different compared with Scrivener.
NSTextView (one item copied):
\f0\fs36 \cf0 \'95 Regular list item}
Scrivener (one item copied):
\f0\fs32 \cf0 {\listtext \uc0\u8226 }Regular list item}
Note how Scrivener places the correct formatting on the clipboard.
NSTextView (two items copied):
\f0\fs36 \cf0 {\listtext \uc0\u8226 }Regular list item\
{\listtext \uc0\u8226 }Another list item}
When copying two list items, it works as expected.
What am I missing? Or is this a bug/feature and the Scrivener folks are working around this in their app (e.g. detecting when a single list item is copied and fixing its attributes)?
It's a "feature".
Try placing your cursor at the start (rather than the end of the line) and dragging down to select the line, copy, paste - you'll get a return at the end of the paste but if you back up to the end of the pasted line and hit return you'll find you get the list formatting.
The formatting details for a "paragraph" are attached to the newlines, also when text is copied formatting info for the start of the selection is included.
The source of TextEdit is available from Apple, the linked version is a few years old and Apple's documentation archive, you might find a newer version in the new "improved" documentation Apple provides, or lose your sanity looking ;-(. If you read it you can find out how these features/quirks of the text system are dealt with.
HTH
I will append some strings to NSTextView, but I want them to start at the bottom. New appended string should go underneath the last appended string.
In Java or C#, one can set VerticalAligment = bottom, but I can't find any appropriate way to achieve this in Cocoa... Any thoughts?
EDIT:
I guess I didn't specify precisely enough what I want, so I'll append two pictures. First is what it looks now, second one is what I want. Basically, the newest string is always at the bottom and the older ones gets pushed up. Makes sense now?
I'm writing a script to handle some layout and I've come across some odd behaviour when creating footnotes.
Whenever I create the footnotes with the script, they appear before the next paragraph which is of a different style to the paragraph containing the footnote. Unless it reaches the end of the story in which case they will appear at the bottom of the page.
I would like for it to behave the same way as when you insert a footnote via the menu, I.E. placing the footnotes together at the bottom of the page.
Here's a before and after:
Here's the relevant code which creates the footnotes. references is an array containing the superscript references in the text (as a character or range of character objects). footnotes is an array containing the footnotes between the #FootnoteB and #FootnoteE tags as paragraph objects.
for (var i = 0; i < references.length; i++) {
// Create footnote
newFootnote = textPara.parentStory.footnotes.add(LocationOptions.BEFORE, references[i].insertionPoints[0]);
// Move footnote text into the footnote
footnotes[i].move(LocationOptions.AFTER, newFootnote.insertionPoints[-1]);
// Remove \r at the end of the footnote
newFootnote.characters.item(-1).remove();
// Delete the leftover superscript reference
references[i].remove();
}
It seems to make no difference where I add the footnotes, whether I add them to the paragraph, story or text frame, the result is the same.
I would check the paragraph styles that appear after the footnotes for their ParagraphStyle.spanColumnType value. I'm not sure if it's a bug or a feature, but if your paragraph spans columns the footnote will appear above it (as if it were the beginning of a new column).
Through the UI, you can check this by editing the paragraph style and checking its Span Columns tab.
ETA: the values you would want in order to avoid the footnote placement you have now are SpanColumnTypeOptions.SINGLE_COLUMN or, via the UI, just Single Column.
How do I place a small paragraph within a text field or label? Do I use code for the new line? I'm using Interface Builder with Xcode.
You could also try using an Text View (NSTextView/UITextView) instead of a text field or a label.
You must mean more than one paragraph, because a single paragraph doesn't need a new line. Just copy it out of a text editor and paste it in.