User forums > Using Code::Blocks

Editor help - does it work with macros ?

(1/2) > >>

Brane2:
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: ---char * str1 = "my_string_abc" ( doublequotes)
--- End code ---

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: ---char myarr[] = { 'my_char_string' }
--- End code ---

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).




Brane2:
And, although I need it for a char type now, it would be really nice if it could work for other integers, too...

stahta01:
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.

oBFusCATed:

--- Quote from: Brane2 on May 14, 2017, 08:09:03 pm ---...and for another, it automatically appends \n at the end.

--- End quote ---
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.

Brane2:

--- Quote from: stahta01 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.

--- End quote ---

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

Navigation

[0] Message Index

[#] Next page

Go to full version