Author Topic: Reviving old macro notepad.e - push current selection into always-on-top window  (Read 651 times)

namklak

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Greetings,
Intro: I'm an embedded C programmer and have used SE for over a decade at different companies, and know almost nothing about the current Slick-C.
I'm trying to revive an old macro I had laying around from who knows what old version of SE.  It is run from the SE command line.  It's supposed to take the currently selected text and copy it into an always on top window.  It fails at runtime with this Slick-C Stack dump:
----
 This property or method is not allowed on this object
notepad.ex 365 notepad()   p_window_id: 259   p_object: OI_LIST_BOX   p_name: editwin
stdcmds.ex 8408 command_execute()   p_window_id: 330   p_object: OI_EDITOR   p_name:
stdcmds.ex 8723 split_insert_line()   p_window_id: 4   p_object: OI_TEXT_BOX   p_name:
----

So in notepad.e, on line 66, it calls copy_to_cursor - this is where it fails.  Method copy_to_cursor is a built-in, so I can't trace it with the debugger.  At least I don't know how to...  So I'm stuck here.

Also, the call stack is kind of hard for me to decipher.  This pops up in SE and I can double click on each entry.  Click on notepad.ex takes me to notepad.e line 66.  Clicking on split_insert_line takes me to that fn where is calls command_execute - so the call stack seem to be reversed?

Please either:
1) help me debug this;
2) tell me what feature is now in the current version of SE that does this so I don't have to use this macro.

Thanks,
-Bob

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2074
  • Hero Points: 101
It sounds like the current window is something you can't call copy_to_cursor on.

How big is the macro?

Graeme

  • Senior Community Member
  • Posts: 2117
  • Hero Points: 257
If you change OI_LIST_BOX to OI_EDITOR it doesn't crash and sort of works but probably needs some adjustment.
e.g.
      if (_select_type()=='CHAR') {
         editorwid.insert_line('');
      }

Is notepad_number supposed to be an incrementing number?

Maybe the append_to_clipboard command is what you want.



namklak

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
If you change OI_LIST_BOX to OI_EDITOR it doesn't crash and sort of works but probably needs some adjustment.
e.g.
      if (_select_type()=='CHAR') {
         editorwid.insert_line('');
      }

Is notepad_number supposed to be an incrementing number?

Maybe the append_to_clipboard command is what you want.

Graeme,
Thanks, changing to OI_EDITOR fixed the crash!

Now I'm trying to get this to window to resize to just the size of the text.  I found this version of notepad.e on this forum, I don't think it's the version I had, because mine resized to the text size automagically.

Thanks again!

Graeme

  • Senior Community Member
  • Posts: 2117
  • Hero Points: 257
Here's a modified version.  There's some #defines at the top you can set - MAX_WIDTH_IN_PIXELS is the max width when it auto-sizes according to the length of the longest line.  You can set def_notepad_font to e.g. Consolas,13  - or leave it blank and it will use a default.

I had some problems with insert_line  - it seems to always insert after the current line even though my config options are set to insert before.  I don't know how it will behave for other people.  There's two commands - xnotepad copies the current line if there's no selection and xnotepad_word copies the current word if there's no selection.  If you don't want the prior selection to be retained after calling the macro, then comment these two lines
      if ( !no_selection )
         _show_selection(oldsel);

I've added lots of spaces as I dislike code that has no spaces around operators - I wish slick beautify could do this automatically.  It should be fairly obvious what the code is doing so you should be able to fiddle with it if it's not exactly what you want.  I'm guessing the original version was written by someone at SlickEdit.

namklak

  • Junior Community Member
  • Posts: 4
  • Hero Points: 0
Graeme
THANK YOU!!!!
Apparently this forum supports a "hero" recognition, but I couldn't find how to do that.  So if you are ever in the Denver/Boulder area, I'll by you a beer or coffee or a even bud because we have that here.  ;)
Thanks again,
-Bob