ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
From: Marco Patzer <homerow@lavabit.com>
To: ntg-context@ntg.nl
Subject: Re: How to display source in ConTeXt?
Date: Tue, 13 Nov 2012 11:42:15 +0100	[thread overview]
Message-ID: <20121113114215.285b4dc3@homerow> (raw)
In-Reply-To: <CAKXgZ3ZHRTgPfOUfc1bXiPQo6j303_8wHHJ90gCn-bBewyR_cg@mail.gmail.com>

2012-11-13 yang.zhao:

> is there a good way to display source(such as C language)  in ConTeXt?

There is the vim module. It uses the editor vim to mark up the
source with syntax highlighting code. However, it does only
highlighting, not indentation. But it might be possible to hook in
an auto-indenter or a formatter like `astyle`. Here's an example:

\usemodule
  [vim]

\definevimtyping
  [C]
  [syntax=c,
   style=smalltype,
   tab=2]

\starttext

\startC
void EBI_BankByteLaneEnable(uint32_t banks, bool enable)
{
  EFM_ASSERT((banks & ~(EBI_BANK0 | EBI_BANK1 | EBI_BANK2 | EBI_BANK3)) == 0);

  /* Configure byte lane support for each selected bank */
  if (banks & EBI_BANK0)
  {
    BITBAND_Peripheral(&(EBI->CTRL), _EBI_CTRL_BL_SHIFT, enable);
  }
  if (banks & EBI_BANK1)
  {
    BITBAND_Peripheral(&(EBI->CTRL), _EBI_CTRL_BL1_SHIFT, enable);
  }
}
\stopC

\stoptext


Marco

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


  reply	other threads:[~2012-11-13 10:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  9:45 yang.zhao
2012-11-13 10:42 ` Marco Patzer [this message]
2012-11-13 12:43   ` yang.zhao
2012-11-13 13:19     ` Martin Schröder
2012-11-13 13:29       ` Pontus Lurcock
2012-11-13 15:41         ` Alan BRASLAU
2012-11-13 14:16       ` Martin Schröder
2012-11-13 16:46       ` Khaled Hosny
2012-11-14  1:04         ` yang.zhao
2012-11-14  1:20           ` Aditya Mahajan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121113114215.285b4dc3@homerow \
    --to=homerow@lavabit.com \
    --cc=ntg-context@ntg.nl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).