Introducing My Free Better Code Editor (BCE) Control

I’m really pleased to announce the immediate availability of my Better Code Editor (BCE) Xojo control.

BCE is a free and open source drop-in code editor for desktop Xojo projects. It’s written in 100% native Xojo code and does not depend on any commercial third party plugins. It is fully API 2.0 compliant and therefore requires Xojo 2019r2.1 onwards.

The editor is a subclass of DesktopTextInputCanvas which requires the installation of the free and open source TextInputCanvas plugin from Einhugur Software. I have included this in the BCE GitHub repository.

BCE requires Xojo 2021r3 because it is a subclass of DesktopTextInputCanvas and not TextInputCanvas. I made this choice because I like to stay current with Xojo’s latest release and I don’t want to maintain two branches. I wanted to be able to use BCE on the new DesktopWindow classes introduced in 2021r3. In theory, there is no reason the control won’t work on Xojo versions from 2019r2.1 onwards but you will need to manually change the superclasses of several of the BCE helper classes.

Features

  • Rich JSON-based theme system to easily style the editor’s appearance and its textual contents
  • Support for a wide variety of programming languages through formatters written in Xojo
  • Different cursor styles (vertical bar, block and underscore)
  • Optional line numbering
  • Support for displaying invisible characters
  • Full support for non-ASCII characters such as emoji
  • Rich tokenisation system allowing for clickable tokens (e.g. URLs in code)
  • Support for highlighting delimiters around the cursor
  • Block highlighting with featuring highlighting of unclosed blocks
  • Hooks for autocompletion with easy-to-style suggestions popup
  • Support for setting breakpoints, bookmarks and compiler warning/error flags in the gutter
  • Actively maintained and updated for the new Desktop UI controls introduced in Xojo 2021 release 3
  • Works on macOS, Windows and Linux
  • Fast. Able to handle thousands of lines of code without slow down
  • Support for commenting / uncommenting out individual lines or blocks of code
  • Customisable undo/redo system
  • Can count total lines of code (or just lines of source code, excluding comments)

I’ve made two YouTube videos that might be of interest to you:

  1. Introducing BCE. This shows the demo in action and what you can do with the control
  2. BCE - Under The Hood. This video goes into a bit more detail about the architecture of the control.

Requirements

  1. The minimum supported Xojo version is 2021 Release 3 (2021r3).
  2. The BCE control can only be added to a DesktopWindow (introduced in 2021r3). This is not a technical limitation but a resource limitation.
  3. You must install Björn Eiríksson’s free open source TextInputCanvas Xojo plugin (Einhugur Software - Open source projects).
  4. You must use the Text datatype rather than String when interacting with BCE. This is because the native Xojo String datatype doesn’t handle emoji and other extended Unicode characters correctly (see [this Xojo forum thread][text thread]). I appreciate that Text is a deprecated datatype but according to Xojo’s CEO Geoff Perlman, it’s not going anywhere anytime soon.

Please let me know what you think of the control. It represents hundreds of hours of work and I’m very proud of it.

15 Likes

This is a very comprehensive control Garry - thank you for providing this to the community. Now to find the time to have a play around with it!

1 Like

Oh this is too cool. Good chance I add this to my app. Might even get some pull requests from me some day.

3 Likes

Sounds awesome! Can’t wait to try it out.

1 Like

If I launch the dev harness project then I get the please locate this and that file hell. (I might be misunderstanding something)

First file it complains about is BetterDictionary.

Those here are empty (Dont know if they should be or not):

PS your Video of it looks awesome !

2 Likes

I wish Xojo handled external classes better than it does. I think the empty folders arise when you make a folder in the IDE containing external classes and then save in Xojo Project format. By default, Git doesn’t save folders with no contents.

To solve this, you need additional components:

They are in different repositories because I use them in loads of different projects. If you clone them and then point to them when the project loads, the IDE should stop complaining.

BetterDictionary is in my Xojo-Collections repo. It appears I omitted that from the README. Apologies, I’ve updated it now.

Thanks!

what software did you use to make the video?

how did you put little Garry at the right hand corner without background??

I think maybe the problem was then that I downloaded the repo as Zip instead of cloning maybe.

I will try again tomorrow and do it the proper way.

Thanks

1 Like

I use ScreenFlow (macOS only).

I record myself using the FaceTime camera and ScreenFlow added a filter to remove the background with a recent update. You can easily resize the FaceTime track and position it in the corner.

It’s great software.

I might try and make a GitHub release tomorrow if I get a chance m with all the requirements internalised into a binary project to make it easier for people to try.

Is it X-Platform (well mac-Win - don’t care about linux) or just for Macs?

-Karen

Do you know where Xojo draws the line to consider something like a “development tool”?

Does any proyect that includes a Code Editor falls into the EULA rule to include a “Made with Xojo” logo?

pretty sure we use ScreenFlow… 15 years ago…

I am looking forward to playing with this, and I guess I should be grateful that the incomplete project has saved the waning hours of Thanksgiving. :slight_smile:

I think the DesktopWindow requirement is probably the biggest hurdle for my adoption.

1 Like

Cross platform desktop. Works on macOS, Windows and Linux. Developed on a Mac.

This is not a commercial project. Maybe if I’m lucky Xojo will see how much I care about the tool and give me a job :slight_smile:

I totally forgot it was thanksgiving when I released this (I’m in the UK). Probably not the best day to launch a new project!

@Björn_Eiríksson: I’ve added a binary project to the repo (src/Legacy Binary Project/) that has all the classes internalised. You should just be able to run the project and it will work.

I don’t want to derail this thread with a rant about the new desktop controls. I wish they hadn’t been introduced but we are where we are. It should be pretty easy for you to get it working on the old Window controls (it was mostly developed in Xojo 2021r2). I think all you’ll need to do is change the super of BCECanvas to TextInputCanvas (instead of DesktopTextInputCanvas and change the super of BCEEditorContainer to be DesktopContainer instead of ContainerControl. You’ll probably also have to rename a couple of Opening events to Open.

1 Like

Sorry @Thom_McGrath:

I meant change from DesktopContainer to ContainerControl.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.