Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: CodeEditor, Assist++, Topic++ » CodeEditor: CopyWord; SwapChars [FEATURE REQUEST][ADDED]
CodeEditor: CopyWord; SwapChars [FEATURE REQUEST][ADDED] [message #2592] Tue, 18 April 2006 13:50 Go to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
Hi

I've written CopyWord and SwapChars for CodeEditor coz these are things I use a lot. They seem to work (including when hard tabs are involved) - I tested them a little bit ... Smile - but only on Win XP. Hopefully Mirek could consider adding them to CodeEditor.cpp, if he has time and wants to ... but if not, that's ok.

It took me longer than the ESC macro versions I wrote a while ago coz there isn't a nice help file of how to do everything like there is for ESC. Surprisingly, TheIDE is sometimes better at navigating UPP source than slickedit! (it's great to have Alt left, Alt right in TheIDE).

I don't know what the clipboard stuff is doing - I just copied the Copy() function. I notice that copying something in TheIDE results in four copies going to the clipboard because I have another editor (EditPlus) that allows me to monitor the clipboard and all copied stuff turns up 4 times in EditPlus Smile

Graeme


void CodeEditor::CopyWord() {
   int p = GetCursor();
   if(iscid(GetChar(p)) || (p > 0 && iscid(GetChar(--p))))
   {
      int e = GetLength();
      int f = p;
      while(--p >= 0 && iscid(GetChar(p)));
      ++p;
      while(++f < e && iscid(GetChar(f)));
      WString txt = GetW(p, f - p);
      WriteClipboardUnicodeText(txt);
      WriteClipboardText(txt.ToString(), false);
   }
}

void CodeEditor::SwapChars() {
   int i = GetLine(cursor);
   int j = GetPos(i);
   if (j < cursor && (cursor-j) < line[i].GetLength())
   {
      int p = cursor;
      WString txt(GetChar(p-1),1);
      Remove(p-1,1);
      Insert(p, txt, true);
      PlaceCaret(p);
   }
}

[Updated on: Tue, 02 May 2006 04:26] by Moderator

Report message to a moderator

Re: CopyWord; SwapChars [message #2734 is a reply to message #2592] Sun, 23 April 2006 14:57 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
Thanks. Just curious - how do you activate those functions? (hotkeys?)

As for 4 pieces on clipboard, that is quite believable - we are putting Unicode and "system page" versions, Win32 then automagically creates other formats from them.

Mirek
Re: CopyWord; SwapChars [message #2741 is a reply to message #2734] Sun, 23 April 2006 20:40 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
luzr wrote on Mon, 24 April 2006 00:57

Thanks. Just curious - how do you activate those functions? (hotkeys?)

As for 4 pieces on clipboard, that is quite believable - we are putting Unicode and "system page" versions, Win32 then automagically creates other formats from them.

Mirek


Oops, looks like I forgot
if(IsReadOnly()) return;
at the start of SwapChars.

I guess SwapChars would be better in LineEdit class anyway, since it's not C++ specific.

Nope, I have it hard coded in CodeEditor::Key at present. I didn't go to the trouble of hotkeys as I wasn't sure if this code would make it into upp sources. Of course I'd definitely like a hotkey option for it but I see that involves quite a few changes. I don't blame you for being reluctant to let people modify sources, especially CodeEditor - I don't think I even really want to. I was hoping it would be an easy thing to copy in from the code I posted.

Ideally, maybe something like an "Others" item on the Edit menu which would give sub-menu of Swap chars, copy word, move line up/down, upper case, lower case ...

Otherwise, I guess it could go in Ide::Key - I'm wondering why that uses editor (an AssistEditor) and not editor2 (CodeEditor) ??

BTW - if save file checked isreadonly() before writing, it would provide a mechanism for avoiding changing a file - currently if you make a change to a file, there's no way to prevent it going to disk other than Ctrl Z/undo. (just a thought)

Graeme
Re: CopyWord; SwapChars [message #2742 is a reply to message #2741] Sun, 23 April 2006 21:36 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
Well, if I am about to add it, I would need to know actual keys Smile

Mirek
Re: CopyWord; SwapChars [message #2743 is a reply to message #2742] Sun, 23 April 2006 23:16 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member
luzr wrote on Mon, 24 April 2006 07:36

Well, if I am about to add it, I would need to know actual keys Smile

Mirek



Um, well, if it's hard coded, I'd probably vote for not adding it and I'll try and do it through Esc, but otherwise ...

In visual studio (and other editors too I think), Ctrl T is transpose chars, shift alt T is line transpose and ctrl shift T is word transpose, but Ctrl T is taken so I'd suggest Ctrl shift T for SwapChars (and I'll swap them over through IDE setup dialog). (I guess the function could be renamed TransposeChars too.)

For copy word, in Slickedit it's Ctrl K by default (VS doesn't seem to have it), so that would be my choice, but I guess Ctrl shift C is a possibility.

Suppose I wrote the code for Esc macros to have copy/paste - would you consider adding it Smile

Graeme
Re: CopyWord; SwapChars [message #2834 is a reply to message #2743] Thu, 27 April 2006 20:46 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
Added. Actually, a good oportunity to add "Special" submenu Smile

Mirek
Re: CopyWord; SwapChars [message #2854 is a reply to message #2592] Fri, 28 April 2006 10:29 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

Thanks. I use these a lot.

Graeme
Re: CopyWord; SwapChars [message #3216 is a reply to message #2854] Sat, 13 May 2006 13:04 Go to previous messageGo to next message
gprentice is currently offline  gprentice
Messages: 260
Registered: November 2005
Location: New Zealand
Experienced Member

Hi

In 605 RC1, The CodeEditor::SwapChars function should probably have
if(IsReadOnly()) return;
added at the start. This was something I forgot to do, but mentioned in a later post.

Graeme
Re: CopyWord; SwapChars [message #3218 is a reply to message #3216] Sat, 13 May 2006 13:49 Go to previous message
mirek is currently offline  mirek
Messages: 12098
Registered: November 2005
Ultimate Member
Thanks!

Mirek
Previous Topic: Assist++: class _DLL_ENTRY __declspec(dllexport) [BUG?][WORKAROUND]
Next Topic: Assist++ "go to..." keys [SUGGESTION]
Goto Forum:
  


Current Time: Thu Nov 14 19:56:54 CET 2019

Total time taken to generate the page: 0.01159 seconds