Selected text in ruby Tk Text widget? - ruby

I can't seem to find how to get the currently selected text from a Text widget in ruby. In perl there was a ->getSelected function, which does not seem to exist in the ruby implementation. Also, the selected text is supposed to be marked with a tag "sel", but whenever I try to use it with get("sel"), it says invalid text index. There must be a way to get the selected text though...
Also, another question, by default, the text widget in perl has a pop menu with all sorts of functionality like search, copy/paste. Was this just a perl specific add on?

Yes, the popup menu in perl is a perl-specific add-on.
As for getting the selected text, you are correct that the selected text has the "sel" tag, and you use that to get the selected text. To retrieve the selected text you should use the index sel.first and sel.last, for example:
get("sel.first", "sel.last")
A really good resource on Tk that covers usage in Tcl, Python, Ruby and Perl see tkdocs.com. The text widget is documented on that site in the tutorial on text.

Of course I finally figured this out right after posting. The index is "sel.first" and "sel.last". so I used get("sel.first", "sel.last")

Related

Finding head section of HTML in Emeditor

I'm trying to use EmEditor to do some find and replace on HTML using regex. I know that Regex is not generally suitable for HTML parsing but I believe it will work for my limited requirement. I can't get it to do some fairly simple finds. e.g. find the head section and remove it. I've tried several different syntaxes e.g. <head.*?>(.|\n)*?</head> also simpler ones where there are no attributes e.g. <head>.*?</head>. None work. What am I doing wrong?
Please try a non-zero value to the Additional Lines to Search for Regular Expressions text box in the Advanced dialog box (Click the Advanced button in the Find dialog box) if you need to search for multi-line strings.

Highlighting search keyword in Slickgrid

I'm developing logs viewer web program with Vue.js
I receive log data with ajax and display it with Slickgrid.
What i need to do is highlighting keyword after searching.
I found some examples highlighting whole cells or row but couldn't find highlighting specific keyword in cell.
ex)When i search a word 'cat', slickgrid shows cells which include 'cat'.
And i need to highlight the word 'cat' in the cell.
Anyone knows how to do this? or any examples??
Thank you.
You'll need to write a custom formatter. See here for an example page. Make sure you're using the 6pac repo - it's up to date, the MLeibman repo is unmaintained now.
Re highlighting a word, you'll need to return HTML from the formatter, and just have a special span to hilight the word, eg:
we will build a <span class="hilight">wall<span/>
It's a tricky business finding a full word, that is making sure it's not part of another word, if that's what you want eg.
did you buy the <span class="hilight">wall<span/>paper yet?
That's a whole 'nother Google search in itself.

Why form class is highlighted as red?

Can somebody tell me which the cause of form class that highlighted as red? What's the meaning of this? I can't get rid of it. I already close the form at the end of the line. But when I view the page source this is what look like.
This is your editor trying to be helpful by highlighting the form tag.
As you're writing HTML make sure you're using an editor that supports more than PHP, like Atom or Sublime Text. Or tell your editor that you're editing HTML.

Ckeditor's Link Dialog incomplete?

In an Xpage running on Domino 9.0.1 I'm using a rich text control with some custom toolbar configuration using the control's "attr" property as it is described here: https://frostillic.us/f.nsf/posts/quick-and-dirty-ckeditor-toolbar-setup-for-xpages
I added the link toolbar template using
<xp:this.attrs>
<xp:attr name="toolbar">
<xp:this.value><![CDATA[[["Link", "Unlink", "Anchor"]]]]></xp:this.value>
</xp:attr>
</xp:this.attrs>
All three buttons are displayed fine, esp. I'm able to define an anchor link target.
But trying to reference the anchor target I find that the Link dialog is somewhat incomplete as I can't define my link to use a relative target on the same page. I tried entering a reference in the dialog's URL field as #myAnchorId, but that results in a link looking like this:
....
Here's an image of the dialog that pops up from my Xpage when I hit the "URL link" button:
And this is what the dialog looks like that I can test from the CKEditor Samples page:
I'm aware that the samples page uses CKEditor V 4, so the dialog is somewhat different, but even V 3.6 should be able to reference anchor links using the dialog.
I already looked up on the installed ckeditor's version; \DominoData\domino\html\ckeditor\version.txt says:
cke_version=3.6.6.2
cke_revision=20130606-1534
Question is: what's missing here? Do I have to somehow modify the dialog?
Oh my, finally got it to work; #IBM: this feature truly could use some proper documentation! I'll mark this answer as a community wiki.
Indeed a different dialog is used here, which btw appears to apply to all the dialogs in use with Domino's CKEditor implementation. The trick in my case is to use one of the custom toolbar items instead of the standard one; up to now I found three of those customized items:
use MenuLink instead of the standard Link item; this item
consists of two sub items ('URL Link' and 'Anchor Link'), each calling its own dialog version; the resulting toolbar definition then looks like this: ['MenuLink', 'Unlink', 'Anchor']
use MenuPaste instead of the standard Paste item; again, this
item consists of two sub items ('Paste' and 'Paste as text'), again
each calling its own dialog version
use LotusSpellChecker to add IBM's own spell checking feature, where CKE's standard spell checker isn't working
I found hints to those three custom items inside my local \DominoData\domino\html\ckeditor\config.js. Don't know if those are all custom items available to day.
EDIT:
IBM's Domino Designer Xpages User Guide mentions another means of customizing the toolbar; the section unfortunately is incorrect in describing the options for the toolbarType attribute: be aware that all named types must start with capital letters, e.g. Basic, Slim, Medium, Large, Full, while the also mentioned Lite type isn't working at all; mistyping or using a non-existing value results in the editor not being displayed at all.
The link dialog that you're using is not the default one, so you should check how to modify it or replace it with the default one.

Sublime Text 2 - Autocomplete questions

I'm loving Sublime text but there are a few things I'd like to configure on the auto-complete:
HTML: Auto-completion of attributes within tags
When adding a class attribute to a div I have to do control+space to get the auto-complete list, is there a way of bringing that up automatically when adding attributes to tags?
HTML: Adding equals and quotes
When auto-completing the class attribute I then have to type the equals and quotes, can they be added automatically?
CSS: Auto-completion of property values
When I autocomplete a property, e.g. position I then have to add a space and press control+space or start typing to get the values autocomplete list. Is there a way of showing this list straight after the property autocomplete?
I've tried searching for an existing solution but can't find one, so I'm hoping there are some config files that I can amend! Any help pointing me in the right direction would be greatly appreciated! Thanks!
Darren
Try control + shift + p -> set syntax HTML in order to get auto-completion on html tags
also install: http://wbond.net/sublime_packages/package_control (streamlines package installation process)
and emmet: https://github.com/sergeche/emmet-sublime (makes writing html/css x times faster)
for more information on configuring sublime text you could check:
http://net.tutsplus.com/tutorials/tools-and-tips/sublime-text-2-tips-and-tricks/
and
http://net.tutsplus.com/articles/news/perfect-workflow-in-sublime-text-free-course/
Definitively for autocompletion install first Package Control and them Emmet from the Palette Command, just search "emmet" and Enter.
If you don't have Package Control installed, do that first. Next find the Tag package through Package Control via ST2 and install it. I believe that's the one you're looking for, otherwise Emmet (Zen Coding) could be the one I'm thinking of. Either way, make sure your document syntax is set to HTML.

Resources