NO

Author Topic: Way to put my code in the forum w color syntax (besides adding color tags) ?  (Read 4292 times)

EdPellesC99

  • Guest

  Hi,

  I have seen code in forums that had color syntax before. With code tags you get indentations, but no color.

  I have seen utilities that would convert the code according to a color syntax file into html ..... but that is not exactly the same as using the tags available for use.

  It would be nice, but doing it manually would be crazy. And I am not that crazy. :)

 Thanks, Ed

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
This forum does not support posting code using syntax coloring.
It might be an add-on available to achieve this.

I have mostly seen syntax colored code only on Wikis.
---
Stefan

Proud member of the UltraDefrag Development Team

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Something like this, but this don't work in code tag?

#include <stdio.h>
//comment
/* comment */
int main(int argc, char **argv)
{
   printf("Hello PellesC\n");
   return 0;
}
May the source be with you

EdPellesC99

  • Guest
Whoops ....

  I never did get a notification that I had responses !! I had the box checked. Maybe I never saw it.
Tx Stefan for your response.

Timo ....
Just saw this and downloaded.

Will get back,

Tx, Ed
« Last Edit: May 16, 2010, 06:49:36 AM by EdPellesC99 »

EdPellesC99

  • Guest

// // ~ •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •

  Timo,
Wow, I cannot believe the nice work you did !!!!



Boy I tip my hat to you !!!!

I am just speechless. Such fine work. I am surprised I was smart enough to get it to work !!!

  Really super. Really impressive. Wow !!!!

  Tx, sure would not have thought something like this could be done.

  Yikes, I feel pretty small !

  Tx, will comment some more in a day or two.

  Best Regards,

  Ed

/****************************************************************************
*                                                                          *
* File    : Export.c                                                       *
*                                                                          *
* Purpose : Add-In for Pelles C - export C source as XXX file.       *
*                                                                          *
* History : Date      Reason                                               *
*           05-03-16  Created                                              *
*                                                                          *
****************************************************************************/

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <windowsx.h>
#include <commdlg.h>
#include <addin.h>
#include <tchar.h>
#include <stdlib.h>
#include <stdio.h>
#include "Export2XXX.h"

#define NELEMS(a)  (sizeof(a) / sizeof(a[0]))

#define COOKIE_COMMENT       0x0001
#define COOKIE_PREPROCESSOR  0x0002
#define COOKIE_EXT_COMMENT   0x0004
#define COOKIE_STRING        0x0008
#define COOKIE_CHAR          0x0010

enum {
   COLOR_TEXT = 0,
   COLOR_KEYWORD = 1,
   COLOR_COMMENT = 2,
   COLOR_NUMBER = 3,
   COLOR_STRING = 4,
   COLOR_PREPROCESSOR = 5,
   COLOR_OPERATOR = 6,
};

typedef struct _PARSEPOINT *PPARSEPOINT;
typedef struct _PARSEPOINT {
   int iChar;               // Column position where text changes...
   int iColor;               // ...to this color index.
} PARSEPOINT;


// Private command ID.
#define ID_EXPORT_XXXX 1

// Locals.
static HANDLE g_hmod = NULL;
static HWND g_hwndMain = NULL;

// C keywords + M$ junk.
static PCTSTR apszKeywords[] = {
   _T("_Bool"),
   _T("_Complex"),
   _T("_Imaginary"),
   _T("_Pragma"),
   _T("__asm"),
   _T("__cdecl"),
   _T("__declspec"),
   _T("__except"),
   _T("__fastcall"),
   _T("__finally"),
   _T("__func__"),
   _T("__inline"),
   _T("__int16"),
   _T("__int32"),
   _T("__int64"),
   _T("__int8"),
   _T("__leave"),
   _T("__stdcall"),
   _T("__try"),
   _T("_asm"),
   _T("_cdecl"),
   _T("_fastcall"),
   _T("_inline"),
   _T("_stdcall"),
   _T("auto"),
   _T("break"),
   _T("case"),
   _T("char"),
   _T("const"),
   _T("continue"),
   _T("default"),
   _T("do"),
   _T("double"),
   _T("else"),
   _T("enum"),
   _T("extern"),
   _T("float"),
   _T("for"),
   _T("goto"),
   _T("if"),
   _T("inline"),
   _T("int"),
   _T("long"),
   _T("register"),
   _T("restrict"),
   _T("return"),
   _T("short"),
   _T("signed"),
   _T("sizeof"),
   _T("static"),
   _T("struct"),
   _T("switch"),
   _T("typedef"),
   _T("union"),
   _T("unsigned"),
   _T("void"),
   _T("volatile"),
   _T("while")
};

#define DEFINE_BLOCK(pos, colorindex)  \
    if (aPoints != NULL) \
    {\
        if (*pcPoints == 0 || aPoints[(*pcPoints)-1].iChar <= (pos)) \
        { \
            aPoints[(*pcPoints)].iChar = (pos);\
            aPoints[(*pcPoints)].iColor = (colorindex);\
            (*pcPoints)++; \
        } \
    }

// Static function prototypes.
static void Export2XXX(HWND, PCTSTR);
static char * XXX_EmitColor(PCTSTR, int);
static UINT C_Parser(UINT, PCTSTR, int, PARSEPOINT [], PINT);
static int IsKeyword(PCTSTR [], int, PCTSTR, int);
static BOOL IsNumber(PCTSTR, int);

/****************************************************************************
*                                                         *
* Function: DllMain                                          *
*                                                         *
* Purpose : DLL entry and exit procedure.                           *
*                                                         *
* History : Date      Reason                                    *
*          04-01-10  Created                                    *
*                                                         *
****************************************************************************/


// // ~ •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •  •


EdPellesC99

  • Guest
  For any others who want my notes on using Timo's Addin.

  Add and enable the addin.


To make up the html file for use in the PellesC forum, Right click the .c file in the editor window background.

See Export C source as XXX to file. New tab opens. File done. Save file. ......... Timo's addin will add ".lst" extent to .c extent.

When you insert the file into a post, do NOT use code tags, use quote tags.

Adjust text size and you must have the size tags inside the quote tags.
So copy the .lst file into the post ..... preceeded (and shown ended by) :

Code: [Select]
[quote][size=9pt]
Here is the .c.lst file
[/size][/quote]


Timo deserves a beer or two for this fine contribution to the forum.
« Last Edit: July 22, 2010, 05:10:01 PM by EdPellesC99 »

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
I just stumbled across GeSHi - Generic Syntax Highlighter, which could be used to allow syntax highlighting in the forums code box.

I don't know, if SMF supports using this.
---
Stefan

Proud member of the UltraDefrag Development Team

EdPellesC99

  • Guest
  I also had found: http://www.brothersoft.com/color-syntax-download-66943.html, in my original look around.

Your recommend looks like more modern software, for sure. And open source, too....

  Both however will no doubt not work any better for the Pelles C forum, and Timo's is free and integrated as an add-in.

  Did I mention Timo's add-in does the job with spectacular results :) :)

  I downloaded GeSHi and will check out, as it looks great for any non-Pelles C IDE work !
  I read on the site, it has been used for Wiki .....

  Thanks,

  Ed

« Last Edit: July 22, 2010, 05:28:43 PM by EdPellesC99 »