How can I move cursor to end of text in ckeditor5 - ckeditor5

ckeditor5
when I used editor.editing.view.focus(), the cursor was at the beginning of the text, how can I move cursor to end of text?

To do that, set the selection in the editor model:
editor.model.change( writer => {
writer.setSelection( writer.createPositionAt( editor.model.document.getRoot(), 'end' ) );
} );

Related

Apache Poi Word Table, information about the Alt Text

How to get the Alt Text from a Table in Word, e.g. Title or Description.
All the Information, that I found had the context, Text, Width, Style etc. to read or modify.
My goal is to identify certain Tables in a Template, so I can modify them.
I am going to make some assumptions here. First that you are talking about the docx format, and second that by "Alt Text" you mean a caption.
A caption is just a paragraph that either precedes, or follows a table. It will have a style of Caption, a run with some text like Table, and probably includes a simple field SEQ Table. That would be the default Table caption, but it could be just a run with a name like Department Heads. The key is the style name. Word uses standard style names to calculate other things as well such as TOC.
Note: in Word, you cannot modify a caption by selecting a table, and clicking a menu option. It isn't really linked in any meaningful way. You have to modify the paragraph.
So to find a caption, you need to look in the Document elements list XWPFDocument.getBodyElements(), and find each paragraph with a style of Caption. Once you have found the one you want, then you can either look at the element immediately above or below to find the table. Your search will be easier if you can know that captions are all above or all below the tables.
So to retrieve the table following a specific named caption I would try something like this:
public XWPFTable FindTable(String name) {
boolean foundTable = false;
XWPFParagraph p;
for (IBodyElement elem : doc.getBodyElements()) {
switch (elem.getElementType()) {
case PARAGRAPH:
foundTable = false;
p = (XWPFParagraph) elem;
if (p.getStyle() == "Caption" && p.getText() == name) {
foundTable = true;
}
break;
case TABLE:
if (foundTable) {
return (XWPFTable) elem;
}
break;
case CONTENTCONTROL:
foundTable = false;
break;
default:
foundTable = false;
break;
}
}
return null;
}
In Word you can set the table caption to something unique, and then get the table in xml:
String tableXML = mytable.getCTTbl();
To extract the table caption:
String[] xml = tableXML.split(System.lineSeparator());
String caption = null;
for (String x : xml)
{
if (x.contains("w:tblCaption"))
{
caption = x.split("w:val=")[1].replace("/>", "");
caption = caption.replace("\"", "");
}
}

Color Text Background in GTK#

I am using GTK# and a TextWidget to display editable text. I want the background color of each item of text to be determined by the character (so that all "A" are red, all "G" are green, all "C" blue, etc.).
It seems this might be possible, but does anyone know an efficient way to tell GTK# to color input text this way?
You can change the colour of the text in a Gtk.TextView by using a TextTag.
An example below creates an error tag, which highlights the text with a red background when the text is inserted.
var textView = new Gtk.TextView ();
var errorTag = new TextTag ("error");
errorTag.Background = "#dc3122";
errorTag.Foreground = "white";
errorTag.Weight = Pango.Weight.Bold;
textView.Buffer.TagTable.Add (errorTag);
string text = "foo";
// Insert text with tag.
TextIter start = textView.Buffer.EndIter;
textView.Buffer.InsertWithTags (ref start, text, errorTag);
text = "bar";
// Insert text then apply tag.
textView.Buffer.Insert (ref start, text);
start = textView.Buffer.GetIterAtOffset (5);
TextIter end = textView.Buffer.GetIterAtOffset (6);
textView.Buffer.ApplyTag (errorTag, start, end);
var vbox = new Gtk.VBox ();
Add (vbox);
vbox.PackStart (textView);
vbox.ShowAll ();

Cognos Checkbox + Oracle Stored Procedure

Here is what I am trying to do
I have a report that looks like this
id name address
id name address
What I would like to do is add a checkbox at the end of each line like so
id name address checkbox
id name address checkbox
What I would like to do is when the user hits the checkbox and hits submit, it will put the id_number into an oracle stored procedure like so
examplestoredprocedure(id_number||,||id_number)
or something similar.
has anyone done anything like this? We have links the user hits and it hits a stored procedure but not with multi values.
Any help would be appreciated
You can do these:
define a procedure on db
//package body on oracle in my case
CREATE OR REPLACE PACKAGE BODY my_package AS
procedure my_procedure ( username in varchar2 ,p_return out sys_refcursor
) as
v_Return varchar2(4000) := null;
begin
--do something
v_Return:=username;
open p_return FOR
SELECT CAST(v_Return AS varchar2(4000))from dual;
end my_procedure;
END my_package;
/
create procedure on your cognos framework
// you should use macros like this :# prompt('p_UserName','string' ,'temp')#
create a cognos report and use javascript//in prompt page
//define checkbox in list with js like this : <input type="CHECKBOX" id="you can define your data item" name="chck1" ></input>
//you should set your values to parameters and then click button like this:
<a title = 'okey'; onClick="myFunction('chck1')">your button</a>
//define function
function myFunction(chkboxName)
{
var checkboxes = document.getElementsByName(chkboxName);
for (var i=0; i<checkboxes.length; i++)
{
if (checkboxes[i].checked)
{
//alert( ' index '+i +' - ' +checkboxes[i].id );
var form = getFormWarpRequest();
var textBox = form._textEditBoxmyeditboxname;//this is important editbox name is : myeditboxname //this is standart : form._textEditBox
{
textBox.value = textBox.value+checkboxes[i].id+',';//this is uses for setting parameter value , you can set your parameter
}
}
}
promptButtonFinish(); //this uses like finish prompt
}
and finally you can set your report page put there your procedure output(:B1)
//put this data item to your page
[Business Layer].[yourdataitem].[:B1]
this is working for me , I hope it solves your problem

Textmate - change #TODO color inside a doc block

I'm able to change an entire documentation block's color inside textmate by using the scope comment.block.documentation
However is it possible to change the color of specific words inside that docblock?
I'm refering to change the color of words or even the entire line like
#TODO
#FIXME
#CHANGED
thanks.
Ok... i was able to find the answer.
Bundles > Bundle Editor > Show Bundle Editor
Select the Language Javascript (note... the language has a L icon inside the Javascript item on the left list)
find for the scope named comment.block.documentation.js and modify it accordingly
{ name = 'comment.block.documentation.js';
begin = '(/\*\*)\s*$';
end = '\*/';
beginCaptures = { 1 = { name = 'punctuation.definition.comment.js'; }; };
endCaptures = { 0 = { name = 'punctuation.definition.comment.js'; }; };
patterns = (
{ name = 'meta.documentation.tag.todo.js';
begin = '((\#)TODO)';
end = '(?=^\s*\*?\s*#|\*/)';
},
{ name = 'meta.documentation.tag.fixme.js';
begin = '((\#)FIXME)';
end = '(?=^\s*\*?\s*#|\*/)';
},
{ name = 'meta.documentation.tag.changed.js';
begin = '((\#)CHANGED)';
end = '(?=^\s*\*?\s*#|\*/)';
},
);
},
after you just have to change the color on the prefs window, using the declared selector!

Insert text into flex 3 textarea

I have a textArea and a list. When a user double clicks a list item, the label of the selected item should be inserted into the textarea. When a text is selected in the textArea, it should be replaced, otherwise the text just needs to be inserted into the existing text at the caret point.
I've managed to get the text and everything, I just can't manage to insert it at the caret point. Does anyone know how to do this?
It's actually not JavaScript but Adobe Flex 3. Thanks for the help though, it did push me in the right direction. This is the way its done in Flex 3:
var caretStart:int = textArea.selectionBeginIndex;
var caretEnd:int = textArea.selectionEndIndex;
textArea.text = textArea.text.substring(0,caretStart)
+ newText
+ textArea.text.substr(caretEnd);
The accepted answer works great if you do not have existing HTML formatting. In my case, I inserted a new button into the editor that the user could click to put in a key word. I kept losing all HTML formatting until I dug around in the actual class and sided with a TextRange object:
public function keyWord_Click(event:Event) : void
{
var caretStart:int = txtEditor.textArea.selectionBeginIndex;
var caretEnd:int = txtEditor.textArea.selectionEndIndex;
var newText : String = "[[[KEYWORD]]]";
var tf:TextRange = new TextRange(txtEditor,true,caretStart,caretEnd);
tf.text = newText;
}
The nice thing about this approach is, you can also apply conditional formatting to that TextRange object as needed.
You can use txtarea.selectionStart and txtarea.selectionEnd to get Selected text position.
After that, You delete txt and add new selected text.
I don't known much about Javascript, so I wrote it for U.
You can search on google with keywords:
"Javascript Selected Text TextArea"
"Javascript add text at position"
Sample code:
function insertAtCursor(myField, myValue) {
//IE support
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
}
//MOZILLA/NETSCAPE support
else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
caretPos = doGetCaretPosition(myField);
alert(caretPos);
setCaretPosition(myField,caretPos-3);
}