00:00
00:00
ciclopeninja
"I do things, I explode, I engineering code, only for fun"
--Maybe someday it will take me somewhere
--...
-- SKNW.

------- ADA IS MY SWORD and MY GOD ------- - DESTRUCTION IS A FORM OF CREATION - @ciclopeninja

Age 21, π

Language Developer

administration technician

.br

Joined on 7/5/21

Level:
14
Exp Points:
1,886 / 2,180
Exp Rank:
33,740
Vote Power:
5.56 votes
Rank:
Civilian
Global Rank:
82,625
Blams:
0
Saves:
73
B/P Bonus:
0%
Whistle:
Normal
Medals:
23

ciclopeninja's News

Posted by ciclopeninja - 1 month ago


Silvio Santos vem aí! Ole Ole, Olá...


Posted by ciclopeninja - 1 month ago


CLEAR TERMINAL IN ADA


iu_1252374_9521393.webp


Most people don't know how to clear terminal text in a program made in gnat Ada


Ada don't have this

...


This depends on your OS (Win, Linux, Mac, etc...), as in windows the command to clear a terminal is "cls", so for your operating system you need to activate this command, but normally it is not available in Ada, this means you need to import "system" into your project and then use "cls" inside...


If you have some knowledge of Ada, you know you can do this using "Intefaces C" (portable ABI) : Interfaces.C & Interfaces.C.Strings.


then you can make a procedure like this:


  Procedure Clear_Screen is 
    procedure System (Command : Interfaces.C.Strings.chars_ptr);
    pragma Import (C, System, "system");
    CLS : constant Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String("cls");
  begin
    System (CLS);
    -- if you want to draw somenting after you clear the terminal you can do this here :)
    --Put_Line("The prompt is clear...");
  end Clear_Screen;

this will clear the text in the terminal generate by Ada gnat.


For unix systems it can be more simple in theory, using only Put command:


Put (ASCII.ESC & "[2J"); --clear
Put (ASCII.ESC & "[H"); -- move cursor to the top

I not a Linux user, I use Windows and FreeBsd, if that simple command don't work you can try the first one for the linux too, using "clear" instead "cls":


  Procedure Clear_Screen is 
    procedure System (Command : Interfaces.C.Strings.chars_ptr);
    pragma Import (C, System, "system");
    CLEAR : constant Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.New_String("clear");
  begin
    System (CLEAR);
    -- if you want to draw somenting after you clear the terminal you can do this here :)
    --Put_Line("The prompt is clear...");
  end Clear_Screen;

At this point you've figured out that for your operating system or the operating system you want to support, the idea is the same.


If anyone has another idea on how to clear the terminal, or any doubts, please comment. <3


The End :P


Tags:

Posted by ciclopeninja - July 15th, 2024


ADA COLORS FOR VIM



iu_1237317_9521393.webp

TERMINAL:

iu_1237318_9521393.webp

iu_1237319_9521393.webp


QT:

iu_1237320_9521393.webp

iu_1237321_9521393.webp


HELLO FRIENDS! (^ ~ ^)


This is my theme for programming in the ADA language. You could say it is a lot of colors but believe me, it is a great help for you to understand if you are doing the right thing in a language like ADA.


You can get it here: GIT HUB, just install and drop into your color files.


  • I recommend: using it with lspconfig and "ada_language_server" so you can have all the colors.


You can config like this:

SIMPLE EXAMPLE:
lua <<EOF
  -- Set up lspconfig.
  -- Setup language servers.
  require("mason").setup()
  require("mason-lspconfig").setup({
    ensure_installed = { "gnatls", "forth-lsp", "clangd", "pylsp", "als" }
  })


  local cmp_nvim_lsp = require('cmp_nvim_lsp')
  local util = require('lspconfig.util')
  local capabilities = require('cmp_nvim_lsp').default_capabilities()
  local lspconfig = require('lspconfig')


  require("lspconfig").clangd.setup { 
    capabilities = capabilities 
  }


  lspconfig.als.setup {
    capabilities = capabilities,
    cmd = { "ada_language_server"},
    filetypes = { "ada" },
    settings = {
      als = { gpr = "YOUR GPR FILE PATH HERE.gpr" }
    }
  } 
EOF


  • I tried to create a theme for the FORTH language but it didn't help much, but you can try to use if you want.


If you want to change some colors I'll give you a quick tutorial here:


Changing Colors!

INIT
highlight <-- Token name for what will be highlight

highlight NAME <-- Variable Name (example: String, Number, AdaNumber, AdaString, etc)
I recommend that you try to find the list of variable names on the internet for the language you use
cterm <-- Terminal
bg    <-- background
fg    <-- font color
ctermfg, ctermbg, cterm

examples:
highlight AdaString  ctermfg=84  ctermbg=NONE <-- hexadecimal color code does not work for cterm you need to use color code 0 to 255, some colors may not work in your terminal emulator, simple cmd terminal only works with colors (0 to 16)

highlight AdaString  ctermfg=84 cterm=italic <-- you can youse to make font efects on your code


gui <-- gui type window
bg  <-- background
fg  <-- font color
guifg, guibg, gui

examples:
highlight AdaString  guifg=#00ff87  guibg=NONE gui=italic <-- you can youse to make font efects on your code
Mabe you cannot find the name of some variable then you can try to force the color like this:


syntax match AdaAssignment /:=/
highlight link AdaBeginEnd AdaKeyword

  • Sometimes it may conflict with another highlight, be aware


The End :P


Tags:

1