Categories
Tools

Pretty Printing Your Source Code

A picture is worth a thousand words, but how do you include source code in a presentation? By text or by image?

Nick Hodges asked about this on Facebook the other day.

Here are some of the suggestions from the community (with my commentary), followed by a few of my suggestions.

  • Robert Love suggested Slides.com – it is a paid web based presentation service centered around web standards. It includes built in features for making your code snippets look nice. Pro: Includes the code as text. Con: One more monthly fee (there is a free plan).
  • Glenn Dufke suggested pasting the code with Syntax Highlighting preserved – By default the RAD Studio/Delphi IDE doesn’t maintain this, but the GExperts IDE Plugin has a Source Code Export expert (I used to use this). I’m sure there are others (CnPack maybe?)
Source Export
GExperts Source Export Export
  • David Schwartz suggested just doing a screenshot from the IDE – this preserves your artistic view of how you have your IDE configured. Downside is the code can’t be easily extracted from the slides . . .
  • Bruce McGee suggested reveal.js – I’ve not used it yet, but it is a full web standard presentation framework, and looks promising. It uses highlight.js for the syntax highlighting, which I have used. With support for 185 languages, it has you covered. I’ll certainly be checking that one out. Thanks Bruce!

Now for my suggestions. In the past I’ve used the rich export options like Glenn suggested, colorized the text by hand, or used an intermediary like Notepad++, etc. But here are some options specifically around creating code screenshots.

Greenshot – is my current preferred desktop screenshot tool for pulling images directly from the IDE. It includes a nice editor for your screenshots too, so you can quickly annotate them, blur things out, etc.

Greenshot screen shot image editor

Carbon.now.sh is a web page that takes your code and converts it into a nice image with a macOS style window. There are a few customization options. If you embed it or share it via URL then it provides both the source code and the preview. It doesn’t list Delphi as a language, but the Pascal support is close enough.

Sample from Carbon.now.sh

Codeimg.io is similar to Carbon, but has more configuration options. The best part is that you can use templates sized exactly for different social media platforms. A lot more customization options, including both Windows and macOS window styles. It doesn’t appear to offer a share by URL or embed option, and only does the image generation. For some reason it defaults to a JPG instead of a PNG for the image though (also supports SVG). Newer addition and still in beta.

Codeimg.io

src2img is a no-nonsense straightforward converter that turns out Source into a PNG file. Just select language (auto detects Delphi) and style. It is based on highlight.js and the source is on GitHub. Doesn’t offer a link share, just image download.

Instacode is the Instagram of the bunch, with image filters like tilt shift and 3D rotation. Directly supports Delphi language, and you can share via a URL that allows someone to access the code and remix the image. Even has wallpaper generator.

Image result for photoshop logo

Lastly, if you have some Photoshop skills (or can follow tutorials like I do) then you can make your own. This is a combination of screenshots, with perspective warps, a few filters, background images, etc.

Did I mention CodeRage 2019 is coming soon?

How do you pretty print your source code? Which of the above is your favorite, or what did I miss?

Categories
News

Delphi Live! 2009 – What is Cooking in the Delphi Labs – Part 3

Another video from Delphi Live! 2009 . . .

Nick Hodges, Delphi R & D Manager
Allen Bauer, Chief Scientist

Embarcadero Technologies

DelphiLive! 2009
May 2009 in San Jose

This is part 3 where we see more of the code formater.  Also the non-modal find box.  Then Allen takes over to show off the Direct2D canvas.  I zoomed in pretty good so you can see the differences.    At the very end you see the email from David I. saying he is ready for his demo next.

[Part 2] – [Part 4]

Categories
News Video podCast

Intro to Generic Collections with Delphi 2009

A very short introduction to Generic Collections in Delphi 2009. Create a TList of Integers and show adding and removing items from it. Showing some of the differences in types, gotchas and errors you might get.

Generics, or parametrized types, are a type that works with another type that is defined later. Collections are a great example of using them. You create a generic TList, and then when you use it you declare what type it will contain. Then it will be strongly typed to that specific type, both in adding items and removing them.

Delphi Generics work with all types in Delphi: native types (Integer, string, etc.), Records, Objects and Interfaces.

This is screen cast episode 2, shot with Camtasia and hosted on Vimeo.  I had to shoot it at 1280×720 so they will offer it in HD and not downscale it.  Let me know how it works for everyone.

As was pointed out in the comments, the download link only works after you sign into Vimeo.  If that doesn’t work for people let me know and I will come up with a different solution.