Re: C grunt work - how to automate with BBEdit?

2020-01-29 Thread GP


On Tuesday, January 28, 2020 at 12:45:41 PM UTC-8, Sam Hathaway wrote:
>
> There are two tasks I end up doing manually in C a lot and I’d like to not.
>
> Thing one: putting guards around header files.
>
>  

> [snip]
>
 

> Thing two: maintaining function prototypes in header files.
>

[snip] 

Look at the "Filters and Scripts" section of BBEdit's User Manual.  Amongst 
other environment variables, BBEdit sets BB_DOC_NAME and BB_DOC_PATH. With 
those you can easily check for the existence of the counterpart header and 
if it doesn't exist create one with the appropriate include file guards.

If it was me, I would use Perl for the scripting language since that allows 
you to use the same regular expression as you would use in BBEdit to search 
for C function headers in your .c file(s). How easily that will be depends 
largely upon how clean or ugly you write C code. (Without testing it, I 
think you can reject static function headings using a negative 
lookahead/lookbehind on static in the function heading.) I don't know if it 
is still the case, but BBEdit at one time shipped with a C function header 
grep pattern in the find/search dialogs.  You could use that as a starting 
point to work up to a regular expression that will find just the function 
headings in a .c file that you need/want to generation function prototypes 
for. 

I also wouldn't get too fancy with the prototype updating. Todays machines 
have cycles to spare so just regenerate the whole header contents anew, 
compare old with new, and then replace the old with the new if there is a 
difference between the two. Exactly how fine grained the replacing needs to 
be depends upon how you structure your header files and what else (e.g., 
comments and other non-function declarations) you put in the files. 

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/d5940b6f-2260-4d5e-8ae1-be49f25a9846%40googlegroups.com.


Re: C grunt work - how to automate with BBEdit?

2020-01-28 Thread Steve deRosier
For the include file guards, I'd suggest either looking at the
Stationary or Clippings features. Both should easily do what you want
to varying degrees.

- Steve

On Tue, Jan 28, 2020 at 12:45 PM Sam Hathaway  wrote:
>
> There are two tasks I end up doing manually in C a lot and I’d like to not.
>
> Thing one: putting guards around header files.
>
> Any module.h should start with:
>
> #ifndef MODULE_H
> #define MODULE_H
>
> and end with:
>
> #endif /* !MODULE_H */
>
> I usually get a few minutes into writing the header file and then remember 
> that I need have an include guard. I’d like to be able to hit a key or select 
> a menu item in order to add it. The name of the guard should be derived from 
> the file name.
>
> Thing two: maintaining function prototypes in header files.
>
> Given a file.c, prototypes for all non-static functions should exist in the 
> counterpart file.h.
>
> So given file.c:
>
> void file_init(int a, int b)
> {
> /* stuff here */
> }
>
> static void helper(void)
> {
> /* more stuff */
> }
>
> void file_scan(int a, int c)
> {
> /* and again */
> }
>
> The corresponding file.h should look contain:
>
> void file_init(int a, int b);
> void file_scan(int a, int c);
>
> Again, I’d like to, from a C source file, hit a key or select a menu item to 
> add prototypes in the corresponding C header file. Bonus points if the 
> command creates the header file if it doesn’t exist yet, and adds the 
> appropriate include guard. More bonus points if it can update existing 
> prototypes if I change the return type or parameter list.
>
> Does that all make sense?
>
> I imagine AppleScript would be involved.
>
> Don’t feel like you have to write this for me, but if you already have tools 
> to do this (or part of this) please point me in their direction.
>
> Thanks for any ideas!
> -sam
>
> --
> This is the BBEdit Talk public discussion group. If you have a feature 
> request or need technical support, please email "supp...@barebones.com" 
> rather than posting here. Follow @bbedit on Twitter: 
> 
> ---
> You received this message because you are subscribed to the Google Groups 
> "BBEdit Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to bbedit+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/bbedit/75A92463-3871-4AD6-8546-F8DEFF1DCA2B%40munkynet.org.

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "supp...@barebones.com" rather than 
posting here. Follow @bbedit on Twitter: 
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bbedit+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/CALLGbRJ%2BjgSta3xk%3DwcAZW8McZS6QYEH-u29TKc3ToXKxTQmAw%40mail.gmail.com.


Re: C++

2011-08-19 Thread Maarten Sneep

On Fri, 19 Aug 2011 00:36:21 -0700 (PDT), peter wrote:

should be very simple this [ it is in textmate ]:

I just want to run some *simple* C++ code from within BBEdit. What on
earth is a shebang error ? Can someone give me straightforward guide
how to do this ?


No. #! is for script languages, nog for compiled languages.

Maarten.

--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread Maarten Sneep

On Fri, 19 Aug 2011 00:36:21 -0700 (PDT), peter wrote:

should be very simple this [ it is in textmate ]:

I just want to run some *simple* C++ code from within BBEdit. What on
earth is a shebang error ? Can someone give me straightforward guide
how to do this ?


To be a bit less blunt than my previous response: What do you expect to 
happen?


Do you have C++ source code in the editor, and do you want to run the 
program that would be a result of this? Or do you have a C++ based 
compiled tool, and do you want to process the front document with said 
tool?


The fact that to C++ code is simple doesn't matter. #! supports 
scripts: text files that start with #! and follow on with an interpreter 
for the rest of the script. This tells BBEdit which tool to use to run 
the script. Compiled programs work differently, and cannot be placed in 
#!.


Create a wrapper script around the tool, and run it from there, just 
like any other tool. That assumes the second use case.


Maarten
--
Something like:

#!/bin/bash

TOOL=/path/to/my/cplusplus/tool

$TOOL  /dev/stdin  /dev/stdout

--
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.

To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread peter lindsay
Thanks. It's seems a pity: looks like it's Textmate for me then.

Sent from my mobile

On 19 Aug 2011, at 12:29 PM, Maarten Sneep maarten.sn...@xs4all.nl wrote:

 On Fri, 19 Aug 2011 00:36:21 -0700 (PDT), peter wrote:
 should be very simple this [ it is in textmate ]:
 
 I just want to run some *simple* C++ code from within BBEdit. What on
 earth is a shebang error ? Can someone give me straightforward guide
 how to do this ?
 
 No. #! is for script languages, nog for compiled languages.
 
 Maarten.
 
 -- 
 You received this message because you are subscribed to the BBEdit Talk 
 discussion group on Google Groups.
 To post to this group, send email to bbedit@googlegroups.com
 To unsubscribe from this group, send email to
 bbedit+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/bbedit?hl=en
 If you have a feature request or would like to report a problem, please email 
 supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread Bob Withers
Probably off topic (sorry) but I use a tool called CodeRunner for this:
http://www.macupdate.com/app/mac/38362/coderunner

Regards,
Bob

On Aug 19, 2011, at 2:36 AM, peter wrote:

 should be very simple this [ it is in textmate ]:
 
 I just want to run some *simple* C++ code from within BBEdit. What on
 earth is a shebang error ? Can someone give me straightforward guide
 how to do this ?
 thanks
 Peter
 
 -- 
 You received this message because you are subscribed to the 
 BBEdit Talk discussion group on Google Groups.
 To post to this group, send email to bbedit@googlegroups.com
 To unsubscribe from this group, send email to
 bbedit+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/bbedit?hl=en
 If you have a feature request or would like to report a problem, 
 please email supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread peter
very helpful thanks. I also like this tool very much. It won't show
dynamic input with cin for example but it is very effective.

On 19 August 2011 13:19, Bob Withers b...@pobox.com wrote:
 Probably off topic (sorry) but I use a tool called CodeRunner for this:
 http://www.macupdate.com/app/mac/38362/coderunner

 Regards,
 Bob

 On Aug 19, 2011, at 2:36 AM, peter wrote:

 should be very simple this [ it is in textmate ]:

 I just want to run some *simple* C++ code from within BBEdit. What on
 earth is a shebang error ? Can someone give me straightforward guide
 how to do this ?
 thanks
 Peter

 --
 You received this message because you are subscribed to the
 BBEdit Talk discussion group on Google Groups.
 To post to this group, send email to bbedit@googlegroups.com
 To unsubscribe from this group, send email to
 bbedit+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/bbedit?hl=en
 If you have a feature request or would like to report a problem,
 please email supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit

 --
 You received this message because you are subscribed to the
 BBEdit Talk discussion group on Google Groups.
 To post to this group, send email to bbedit@googlegroups.com
 To unsubscribe from this group, send email to
 bbedit+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/bbedit?hl=en
 If you have a feature request or would like to report a problem,
 please email supp...@barebones.com rather than posting to the group.
 Follow @bbedit on Twitter: http://www.twitter.com/bbedit


-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread David Kelly
On Fri, Aug 19, 2011 at 01:45:46PM +0200, Maarten Sneep wrote:
 
 The fact that to C++ code is simple doesn't matter. #! supports
 scripts: text files that start with #! and follow on with an
 interpreter for the rest of the script. This tells BBEdit which tool
 to use to run the script. Compiled programs work differently, and
 cannot be placed in #!.

Well, close. #! is Unix convention for signaling the path to an
interpreter. If one happens to have a c++ interpreter, then so be it.

I don't know, there may well be a command line syntax to g++ instructing
it to compile and run the remainder of the file and discard the
generated intermediate and final executable after. Or as you say a
script wrapper could be created to do just that:

 Create a wrapper script around the tool, and run it from there, just
 like any other tool. That assumes the second use case.

-- 
David Kelly N4HHE, dke...@hiwaay.net

Whom computers would destroy, they must first drive mad.

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++

2011-08-19 Thread Doug McNutt
At 08:35 -0500 8/19/11, David Kelly wrote:
 Create a wrapper script around the tool, and run it from there, just
 like any other tool. That assumes the second use case.


In the days of MPW and later in the very early days of BBEdit worksheets it was 
possible to include compile, link, and execute commands in the text file that 
was the C source code.

The # in #! was carefully selected to be treated as a comment in most source 
code syntax.

#!/usr/bin/tcsh   (Not needed in MPW which is csh all by itself)
#IFDEF nonsense   (Never defined anywhere!)
gcc myself -o $HOME/bin/somebinary  (or perhaps something in /tmp)
link . . .  (When in MPW)
somebinary
exit
#ENDIF
include ...
main;
print Hello World;
.
# all done



It was possible to execute such a text file just by giving its name or select 
and ENTER in a worksheet. Almost as simple as a deck of FORTRAN cards inserted 
in a card reader for load and go of old.

The technique is still possible for simple things but it sure would be better 
if BBEdit worksheets could once again be executable text files as opposed to 
XML plists.  I can no longer execute a worksheet from another worksheet and I 
miss it.

-- 

-- A fair tax is one that you pay but I don't --

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.
Follow @bbedit on Twitter: http://www.twitter.com/bbedit


Re: C++ plugin?

2010-04-03 Thread fschietteca...@gmail.com
You might want to check this out:

http://developer.apple.com/legacy/mac/library/technotes/tn2005/tn2130.html

A handle is a pointer to a pointer, that's all. Handles were pretty
fundamental to the Mac OS prior to X but don't really make sense
anymore, and the tech note recommends you use malloc() and calloc(),
in fact NewHandle() and NewPtr() just maps to those.

On Apr 2, 8:29 pm, Steve deRosier deros...@gmail.com wrote:
 OK,
 I'm answering my own question.  You just have to extern C the main
 function call:
 extern C pascal OSErr HelloWorld(BBXTCallbackBlock *callbacks,
 WindowPtr w, long flags, AppleEvent* event, AppleEvent* reply)
 {
 ...

 }

 That gets it to work.

 So, now the follow up question: How the heck do you debug a plugin?
 I'd love to run it in a debugger, but I don't really see how to do
 that.  printf/cout tracing doesn't seem possible as there's no
 terminal.

 While I'm very experienced with C/C++ programming in a variety of
 situations (embedded and Linux are my primary fields), I'm fairly new
 to the Mac API and BBEdit plugins specifically.  All of this passing
 around of opaque Handles and use of pascal-style strings has me fairly
 confused.  So, is there a concise tutorial of what a Handle is, how to
 copy the data to/from standard C or C++ strings, what the best
 practices in this are?

 Thanks,
 - Steve



 On Fri, Apr 2, 2010 at 4:03 PM, Steve deRosier deros...@gmail.com wrote:
  I'm trying to write a plugin for BBEdit.  The SDK sample is in C, but
  I'd like to use C++ as there's some existing higher-level
  functionality I'd like to connect with my plugin.  I see the Python
  language module is in C++ (or at least is contained in .cp files), so
  I assume it's possible, but if I compile my plugin as C++, when I use
  it in BBEdit, BBEdit segfaults.

  Does anyone know:

  1. Is it possible to write a BBEdit plugin in C++?
  2. If so, what's the proper incantation to make it work?  Best would
  be if someone could give me an idea of how to go from the HelloWorld
  plugin in the SDK to a version that compiles in C++.

  Thanks,
  - Steve

-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

To unsubscribe, reply using remove me as the subject.


Re: C++ plugin?

2010-04-02 Thread Steve deRosier
OK,
I'm answering my own question.  You just have to extern C the main
function call:
extern C pascal OSErr HelloWorld(BBXTCallbackBlock *callbacks,
WindowPtr w, long flags, AppleEvent* event, AppleEvent* reply)
{
...
}

That gets it to work.

So, now the follow up question: How the heck do you debug a plugin?
I'd love to run it in a debugger, but I don't really see how to do
that.  printf/cout tracing doesn't seem possible as there's no
terminal.

While I'm very experienced with C/C++ programming in a variety of
situations (embedded and Linux are my primary fields), I'm fairly new
to the Mac API and BBEdit plugins specifically.  All of this passing
around of opaque Handles and use of pascal-style strings has me fairly
confused.  So, is there a concise tutorial of what a Handle is, how to
copy the data to/from standard C or C++ strings, what the best
practices in this are?

Thanks,
- Steve


On Fri, Apr 2, 2010 at 4:03 PM, Steve deRosier deros...@gmail.com wrote:
 I'm trying to write a plugin for BBEdit.  The SDK sample is in C, but
 I'd like to use C++ as there's some existing higher-level
 functionality I'd like to connect with my plugin.  I see the Python
 language module is in C++ (or at least is contained in .cp files), so
 I assume it's possible, but if I compile my plugin as C++, when I use
 it in BBEdit, BBEdit segfaults.

 Does anyone know:

 1. Is it possible to write a BBEdit plugin in C++?
 2. If so, what's the proper incantation to make it work?  Best would
 be if someone could give me an idea of how to go from the HelloWorld
 plugin in the SDK to a version that compiles in C++.

 Thanks,
 - Steve


-- 
You received this message because you are subscribed to the 
BBEdit Talk discussion group on Google Groups.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a feature request or would like to report a problem, 
please email supp...@barebones.com rather than posting to the group.

To unsubscribe, reply using remove me as the subject.


Re: c++ clippings

2009-06-16 Thread Rich Siegel

On 6/16/09 at 9:36 AM, markmille...@gmail.com (Simdude) wrote:

It looks like the c/c++ clippings with bbedit is very limited (some
functions headers, comments).

It's intended to function as an example clipping set, and not a 
complete set of C++ clippings (whatever that might be :-)). What 
were you looking for?

R.
-- 
Rich Siegel Bare Bones Software, Inc.
sie...@barebones.com  http://www.barebones.com/

Someday I'll look back on all this and laugh... until they 
sedate me.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups BBEdit Talk group.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to supp...@barebones.com 
rather than posting to the group.
-~--~~~~--~~--~--~---



Re: C# (csharp / mono) language syntax highlighting?

2009-04-21 Thread The Geek Inside

Hello Brian,

I'm working in a Codeless Language Module for C#, is in early release
but is useful, I hope that this help to you.

You can download from:

http://public.me.com/thegeekinside/BBEdit/Languages%20Modules

Best Regards

On Apr 20, 10:06 am, Bryan bceve...@gmail.com wrote:
 Hi,

 Sorry if this is an old topic (I searched pretty thoroughly but you
 never know).

 Is there a C# (csharp / mono) plugin for syntax highlighting in
 BBEdit?  I'm running version 9.1

 Thanks in advance!

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups BBEdit Talk group.
To post to this group, send email to bbedit@googlegroups.com
To unsubscribe from this group, send email to
bbedit+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/bbedit?hl=en
If you have a specific feature request or would like to report a suspected (or 
confirmed) problem with the software, please email to supp...@barebones.com 
rather than posting to the group.
-~--~~~~--~~--~--~---