View Full Version : need input help please.
screwed over
04-27-2007, 05:53 PM
i was simply wondering if it was possible to set a line to a different colour depending on what the first character is (ig a colon means the lines blue) and if so could someone give me an example of this.
im also struggling to get it to add text where the cursor is instead of the end of the input as i can get it to add the text to the end of the input easy.
thanks in advance.
James
RizlaUK
04-27-2007, 06:02 PM
you can not change the text color of a input on a per line basis
for more control over where the text is added use worms caret dll
http://www.indigorose.com/forums/showpost.php?p=51110&postcount=9
screwed over
04-28-2007, 03:48 AM
that smells, thanks for the dll link though
ok, after looking at that project i still have no idea how to insert the text at the cusor position, could you please give me an example? i would be extremely grateful.
RizlaUK
04-28-2007, 08:36 AM
sure,
this code will add any text from the clipboard to the input at the current caret position
-- check if there is any text on the clipboard
isCBText = Clipboard.IsTextAvailable();
-- text is available
if isCBText then
-- get the text from the main input
strText = Input.GetText( "Input1");
-- get the text from the clipboard
strAddText = Clipboard.GetText();
-- get the caret position
cPos=GetCaretPos( "Input1")
cRow=GetCaretRow( "Input1")
-- get the length of the clipboard text string
strAddTextLen = String.Length(strAddText);
-- get the text before the caret
BeforCaret = String.Mid(strText, 1, cPos);
-- get the text after the caret
AfterCaret = String.Mid(strText, cPos+1, -1);
-- reset the text in the input, adding the clipboard text in the right place
Input.SetText( "Input1", BeforCaret..strAddText..AfterCaret);
-- reset the caret to the end of the string that was just added
Input.SetSelection( "Input1", cPos+strAddTextLen+1, cPos+strAddTextLen);
-- scroll to the right line
Input.ScrollToLine( "Input1", cRow);
else
-- there is no text on the clipboard so show a message
Dialog.Message( "Notice", "There is no text on the clipboard", MB_OK, MB_ICONNONE, MB_DEFBUTTON1);
end
output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)
EDIT, you need worms caret dll and enable the clipboard plugin for this to work
screwed over
04-28-2007, 12:04 PM
thanks rizlauk, your now my official #1 hero :D
--edit--
GAH!! im full of problems, how would i copy the text of a selected item to the clipboard, sorry if im being a noob or whatever, but i'm new to APMS and didnt expect so much coding would be needed.
RizlaUK
04-28-2007, 12:29 PM
lol, no problem
just support the cause and buy the t-shrit :lol
RizlaUK
04-28-2007, 12:53 PM
how would i copy the text of a selected item to the clipboard
here, try this:
strText = Input.GetText( "Input1");
cPos=GetCaretPos( "Input1")
cRow=GetCaretRow( "Input1")
selString = Input.GetSelection( "Input1");
if selString ~= nil then
sel = selString.End-selString.Start
Selection = String.Mid(strText, selString.Start, sel+1);
Clipboard.CopyText(Selection);
end
output enhanced with AMS Code Pretty (http://www.indigorose.com/forums/showthread.php?t=19409)
screwed over
04-28-2007, 01:57 PM
no it doesnt work aaargh!!!thanks anyway though.
RizlaUK
04-28-2007, 02:07 PM
it dose work, you cant be using it right
here is the test apz i was using to make your code, try it
screwed over
04-28-2007, 03:42 PM
sorry, i just realised i didnt make my post clear, sorry, i mean a selected item in a listbox, sorry for that, my bad.
Derek
04-28-2007, 04:14 PM
selected = ListBox.GetSelected("ListBox1")
Clipboard.CopyText(ListBox.GetItemText("ListBox1", selected[1]));
Perhaps it would be a good idea to browse thru AMS and the help file to see what is available to you.
The names of the actions (ie: Clipboard.CopyText) is sometimes a pretty good clue :yes
screwed over
04-28-2007, 05:23 PM
hmm, strange, that was the first thing i tried but it would only paste the line number, i wonder what i got wrong, anyway, thank you two so, so much! i wouldnt be able to do it without you!! thanks again!
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.