Author Topic: Editor help - does it work with macros ?  (Read 1487 times)

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Editor help - does it work with macros ?
« on: May 14, 2017, 08:09:03 pm »
Or perhaps is there a way to add similar fuctionality ?

I'd like to be able to define string of chars when working with C, but there is no simple way of doing this.

In C, "my_string_abc" makes a string (= that text + \n" ) somewhere in predefined read-only data space of a program.

That is, usual way of working with strings is:

Code: [Select]
char * str1 = "my_string_abc" ( doublequotes)
But this predefines some things I don't want to be done. For one, it reserves string space in constant memory and for another, it automatically appends \n at the end.

C allows me to work with cahr literals, but those are limited to ONE CHAR EACH. So to make string of them, I have to use

 single qoutes around { 'e' , 'a' , 'c' , 'h', '_', 'c' , 'h' , 'a' , 'r' }, which is killing me.

Quick workaround is to make a simple CLI util which would accept my string and generate separate header file that I could then include.

But that is major drain on my love of life and PITA in general.  :x

Is there a way that I could have some sort of plugin/macro that could automate such things ?

IOW, In C, I can't for example initialize char array with literal succession like:

Code: [Select]
char myarr[] = { 'my_char_string' }
I have to type each char into its own single qoutes and with comma between chars.

It would be very nice to have a macro which could do that and preferably:

- be able to convert either typed-in string or a content of a file.
-have  option for selectable number of columns formatting.
- have option for inserting chars as given in typed string and/or file, their codes in hexa/decimal/octal/binary, their escaped codes like \xxx in hex, octal or bin.
- be able to read binary file, if needed

I suspect this could come very hande for embedded projects ( including various headers, graphic files, icons etc).





Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Editor help - does it work with macros ?
« Reply #1 on: May 14, 2017, 08:44:31 pm »
And, although I need it for a char type now, it would be really nice if it could work for other integers, too...

Offline stahta01

  • Lives here!
  • ****
  • Posts: 6712
    • My Best Post
Re: Editor help - does it work with macros ?
« Reply #2 on: May 14, 2017, 09:43:55 pm »
Please read the rules http://forums.codeblocks.org/index.php/topic,9996.0.html

I have no idea if your question is inside or outside the rules.

Tim S.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 32 bit.
On Debian Stretch, compiling CB Trunk against wxWidgets 3.0.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 12179
    • Travis build status
Re: Editor help - does it work with macros ?
« Reply #3 on: May 14, 2017, 11:11:17 pm »
...and for another, it automatically appends \n at the end.
I hope you've meant '\0' and not '\n', because your statement is not correct!

About the original question:
It would have been good if we've provided the whole scintilla api to scripters, but we haven't.
This is what we have http://wiki.codeblocks.org/index.php/Scripting_commands#cbEditor
It seems that the only way to achieve what you want is to write a C++ plugin that does exactly what you want.
It shouldn't be that hard after you make the plugin compile. :)
If you like you can provide a patch that extends our script bindings to allow you to write such a tool using only scripting.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Editor help - does it work with macros ?
« Reply #4 on: May 15, 2017, 12:48:32 am »
Please read the rules http://forums.codeblocks.org/index.php/topic,9996.0.html

I have no idea if your question is inside or outside the rules.

Tim S.

It's seems  to me I'm in the clear.

Offline Brane2

  • Multiple posting newcomer
  • *
  • Posts: 34
Re: Editor help - does it work with macros ?
« Reply #5 on: May 15, 2017, 12:54:12 am »
...and for another, it automatically appends \n at the end.
I hope you've meant '\0' and not '\n', because your statement is not correct!

About the original question:
It would have been good if we've provided the whole scintilla api to scripters, but we haven't.
This is what we have http://wiki.codeblocks.org/index.php/Scripting_commands#cbEditor
It seems that the only way to achieve what you want is to write a C++ plugin that does exactly what you want.
It shouldn't be that hard after you make the plugin compile. :)
If you like you can provide a patch that extends our script bindings to allow you to write such a tool using only scripting.

Thank you. Will look into Scintilla and C++. But OOP and me seem to live in different universes.  ::)
All that object pr0n, inheritance games, virtual parenting and friends with benefits baffles and disgusts me.

I've read Thinking in C++ several times in every direction and combination, several times backwards.

All I've left with was "Ringing In C++" ;o)

Still, one of these days I'll have to jump in those waters, so why not now ? ;o)

Thanks.