Author Topic: How to integrate another code formatter tools in slickedit?  (Read 417 times)

onlyflyer

  • Community Member
  • Posts: 12
  • Hero Points: 0
Slickedit has a good code formatter, but I found it is not the best one. Now I am using uncrustify instead. I add a custom button to call this command to format current file. But it is not convenient.

I wander how could I do the following thing in Slickedit?
1, Bind a hot key to the custom button
2, Define a custom command to get the selected lines in text file.
   Next step is invoke uncrusify to beautify these lines.
   So, what I need to know is how to get the select lines and how to invoke uncrusify in slick c script.

Thanks!

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1831
  • Hero Points: 74
Re: How to integrate another code formatter tools in slickedit?
« Reply #1 on: May 15, 2017, 02:05:34 pm »
We can help you with this.... but I'm curious what specifically Uncrustify does better?

Tim Kemp

  • Senior Community Member
  • Posts: 513
  • Hero Points: 83
Re: How to integrate another code formatter tools in slickedit?
« Reply #2 on: May 15, 2017, 04:27:26 pm »
Dan,

I can't answer for onlyflyer, but I thought I'd offer my perspective. Where I work, we use a different formatting tool. It's not that it's better, or can do something additional, in fact it may not be as good as SlickEdit, however it is the standard. We are supposed to use that tool with the official formatting options file. I have SlickEdit set up to work similarly, but I expect there are some little differences in the results. I usually remember to run all the code through the formatting tool before I check it in but not always. It would be nice if I could make that an automatic step when I save a file (like stripping off the trailing spaces is).

- Tim

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1831
  • Hero Points: 74
Re: How to integrate another code formatter tools in slickedit?
« Reply #3 on: May 15, 2017, 04:32:32 pm »
I understand.

Occasionally we get requests to support a different diff tool, and we just can't.  It's not "not invented here" syndrome.  It's just that our diff is so intertwined with the product, often using editor buffers that would have to be saved and then deleted, it would be an immense amount of work.  So whenever says "can you make it so I can plug in ________ instead of using your ________?"  my reaction is to say "how can we improve our ________?".

davehohl

  • Senior Community Member
  • Posts: 230
  • Hero Points: 11
Re: How to integrate another code formatter tools in slickedit?
« Reply #4 on: May 15, 2017, 05:39:41 pm »
Dan, perhaps one possibility would be to allow SE to accept configuration files from other tools and perform the reformatting using your built-in beautifier.

jporkkahtc

  • Senior Community Member
  • Posts: 1222
  • Hero Points: 89
  • Text
Re: How to integrate another code formatter tools in slickedit?
« Reply #5 on: May 15, 2017, 05:48:26 pm »
That doesn't solve the problem posted by Tim -- even if the options are set correctly the results may not be exact.

See also: http://universalindent.sourceforge.net/
Someone want to teach this tool about Slickedit?

onlyflyer

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: How to integrate another code formatter tools in slickedit?
« Reply #6 on: May 15, 2017, 06:52:56 pm »
Hi Jporkkahtc,

uncrustify provide thousands of options which is not user-friendly as slickedit formatter. But for me, I like it.

I would like to do this by myself, I think it should not be a hard work by using slickedit c.
I am not familiar with the API, so please give me some hint about how to invoke native app and how to get the selected line information.

Otherwise, I have to search all .e script to find some useful code.

Thanks!

Dan

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1831
  • Hero Points: 74
Re: How to integrate another code formatter tools in slickedit?
« Reply #7 on: May 15, 2017, 07:07:31 pm »
Hi Jporkkahtc,

uncrustify provide thousands of options which is not user-friendly as slickedit formatter. But for me, I like it.

I would like to do this by myself, I think it should not be a hard work by using slickedit c.
I am not familiar with the API, so please give me some hint about how to invoke native app and how to get the selected line information.

Otherwise, I have to search all .e script to find some useful code.

Thanks!

You want to do a selected piece of a file?  The current selection?

jporkkahtc

  • Senior Community Member
  • Posts: 1222
  • Hero Points: 89
  • Text
Re: How to integrate another code formatter tools in slickedit?
« Reply #8 on: May 15, 2017, 07:15:57 pm »
Start with the menu Edit -> Other -> FilterSelection.
This is a quick way to run the currently selected text thru some command line tool

In macro form, it looks like this:
_command joes_filter() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
    _macro('R',1);
    select_all();
    filter_command('sort');
}

Put this into your config folder as "C:\Users\onlyflyer\Documents\SlickEdit\21.0.2\something.e"
Macro->LoadModule
From the slick command line, run  joes_filter
It will sort all of the text in the current buffer.

From Tools > Options > Keyboard and Mouse > Key Bindings
you can assign a key to run this macro.

From Tools > Options > Appearance > Toolbars
You can make a toolbar button to run this macro

onlyflyer

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: How to integrate another code formatter tools in slickedit?
« Reply #9 on: May 15, 2017, 11:12:07 pm »
Hi jporkkahtc,

Thanks for the reply. Maybe I didn't describe clearly because what you input is not what I need.

What I am trying to figure out is invoke a native command in slick c code.
And I also want to bind a key to the custom toolbar button.

I want to do this because I hope I can use hotkey to trigger the beautify function instead of click the button.

Thanks!

jporkkahtc

  • Senior Community Member
  • Posts: 1222
  • Hero Points: 89
  • Text
Re: How to integrate another code formatter tools in slickedit?
« Reply #10 on: May 15, 2017, 11:30:04 pm »
What do you mean by "native command" ?

The macro I show invokes the command line tool "sort.exe".
Presumably, you would replace that with "uncrustify.exe -opt1 -opt2 -opt3", or whatever tool you are using.


Another possibility would be to do this via a Project command.
Open any slick project.
Menu Project -> Project Properties
Select the Tools tab.
Define a custom tool.


Graeme

  • Senior Community Member
  • Posts: 1921
  • Hero Points: 221
Re: How to integrate another code formatter tools in slickedit?
« Reply #11 on: May 15, 2017, 11:42:09 pm »
Not sure if this helps but you can use the shell command e.g.

      shell(get_env('SystemRoot') :+ '\explorer.exe /n,/e,/select,' :+ p_buf_name, 'A');

Search for shell in the help.
Also see the beautify-project command here
https://community.slickedit.com/index.php/topic,11186.0.html

onlyflyer

  • Community Member
  • Posts: 12
  • Hero Points: 0
Re: How to integrate another code formatter tools in slickedit?
« Reply #12 on: May 16, 2017, 12:04:32 am »
Hi jporkkahtc and Graeme,

Thank you both! I will try them out.

slickedit is the most powerful editor in this planet, maybe it's time for me to learn slick c!

Thanks!