Code::Blocks Fortran: theme issue

Hi.

I’ve been using Geany to code for now, but I’m tired of its limitations. I’ve seen Code::Blocks Fortran being recommended a few times here, so I wanted to give it a try. However, I’m currently on Linux Mint 20.2 (XFCE) and I’m always using the dark theme. The problem is that Code::Blocks does not have a dark theme at all, so I think that Linux Mint forces a GTK theme on it, and the result is quite distracting, as shown below:

Does anybody know how I can possibly solve this? Are there any better alternatives? I’ve gone through quite a few threads about IDE recommendations on this Discourse, and C::B and Eclipse were the most recommended (libre) IDEs.

I truly want to give Code::Blocks a try; the features listed here look great, but this default theme is an unnecessary annoyance. I’ve already tried Eclipse, but it hangs frequently on my computer.

Does anybody have any suggestions on how I could either solve this issue or move to another IDE/text editor? I’d like to give Emacs a try as well. The main feature I’m looking for is an implementation of VS Code’s hover/intellisense, or “pop-up documentation” while inputting the arguments of a procedure.

Thank you either way.

1 Like

I haven’t used Code::Blocks for a while, but I believe it should be quite straightforward to change the theme by toggling its settings. I use Geany and Gedit. Could you elaborate on the limitations of Geany as a Fortran editor/IDE? I find it quite powerful.

In terms of IDE, you can also try VSCode:

My personal experience is that VSCode is much slower than Geany and Code::Blocks, which are based on Scintilla.

Thank you for your answer, @fortran4r.

Could you elaborate on the limitations of Geany as a Fortran editor/IDE?

The biggest issue I have with Geany at the moment is the lack of a hover/mini-documentation when using subroutines, functions, etc. With VS Code and Code::Blocks, I’m able to see the types of all variables declared, I have access to this mini-documentation (example) and other quality of life features I enjoy due to how much I’ve used VS Code with Python. I know that Geany can be very useful with all of its plugins, but it won’t solve my problem at the moment.

I appreciate the suggestion nonetheless. If possible, could you tell me how you use Geany? Your plugins, your config. options, and the like? I’d enjoy to give it another chance as well. I must’ve been using it wrong.

I basically use Geany as an editor instead of an IDE. No special settings or plugins are used. If hover/mini-documentation is your concern, then you should consider VSCode.

I use Geany myself for Fortran coding, it’s fast, lightweight and it has all the features I need as a novice programmer. I especially like how it doesn’t automatically check and highlight any syntax errors, etc. while I am typing. More “professional” IDEs (at least Qt Creator) tend to do this. I find that feature very distracting.

There are at least two approaches to follow this idea with multiple supporting Emacs modules.

  • You may write code in one buffer, and subsequent transition into the other one (C-x o) as demonstrated in many of the examples e.g., by Cyprien Rusu’s Fortran video tutorials (example 4:30 mm:ss tuto 2) for compilation and execution

  • You may opt for Emacs org mode (a modern installation of Emacs already includes this as a major mode by default) to write/compile/execute your Fortran code in an .org file.

For illustration of option 2, I add file example.org as a MWE file below:

#+OPTIONS: toc:nil  # disable a table of content if exported to .html

* This is a chapter

  Text may be normal, /italic/, *bold*, _underlined_, or =monospace font=.

  The following defines a simple Fortran program.  Current Emacs orgmode eases
  the input of such a block about /source code/ by input =C+c C+ s=.

  With =fortran=, the syntax highlighting is enabled.  For the code's eventual
  execution, it is exported into file =hello.f90=, in orgmode's parlance
  "tangled", which will reside in the same folder as the current .org mode.

  #+begin_src fortran :tangle hello.f90
    program EvenNumbers
    implicit none
    
    integer :: i
    
    do i = 1, 5
       if (mod(i, 2) == 0) then
           print *, i, " is an even number"
       else
           print *, i, " is an odd number"
       end if
    end do
    
    end program EvenNumbers
  #+end_src

  The following block calls the compiler with bash.  Move the cursor to the
  block, and execute the command by =C+c C+c=.
  #+begin_src sh
    gfortran hello.f90 -o check -Wall -Wpedantic
  #+end_src

  #+RESULTS:

  The executable is used (again =C+c C+c=), the additional parameter in the
  header instructs the format shall be like the one obtained on the CLI:
  #+begin_src sh  :results output
    ./check
  #+end_src

  #+RESULTS:
  :            1  is an odd number
  :            2  is an even number
  :            3  is an odd number
  :            4  is an even number
  :            5  is an odd number

(Apparently, discourse does not yet recognize the org format.)

I like that this approach provides syntax highlighting, and increases the indentation for the next line once the condition is defined. It is possible to tangle multiple separate blocks eventually into one source code file in common; this allows to keep some annotations (like commenting lecture notes) with cross references and personal comments separate from the .f90 source code eventually shared. Or you opt for the export of this plain ASCII file from Emacs in as .tex (and if you have pdflatex, into .pdf), .odt, or .html , e.g., by C-c C-e h o.

Let’s assume I replace else by else if in the Fortran block and tangle this again. The second block (about the compilation) is going to report the anticipated warnings in a buffer opened automatically as soon as I call C-c C-c:

John Kitchin (CMU) is one of the proponents of this approach of reproducible research and demonstrates some benefits in his brief video here (at 11:00 mm:ss onward for basics, at 14:09 mm:ss a specific example for Fortran).

Thank you all for your answers. I’m going to switch to VS Code and later on I’ll try @nbehrnd’s suggestion.

2 Likes