Author Topic: select-code-block for Ada?  (Read 3831 times)

witness9

  • Community Member
  • Posts: 54
  • Hero Points: 2
select-code-block for Ada?
« on: October 23, 2006, 02:27:03 pm »
Is it possible to make the select-code-block feature work with Ada?

Thanks!
witness9

Graeme

  • Senior Community Member
  • Posts: 2411
  • Hero Points: 318
Re: select-code-block for Ada?
« Reply #1 on: October 25, 2006, 11:23:50 am »
Is it possible to make the select-code-block feature work with Ada?

Thanks!
witness9

Probably not, but if you can write a pseudo algorithm to parse code blocks in ADA, it's probably not hard to create a Slick C macro that selects a code block . e.g. the algorithm could be something like

find previous word until one of [begin,for,if,while,whatever]
_select_char() // - slick C code to start a selection
find-end-of-block(...)
_select_char()    // slick c code to end the selection


Procedure find-end-of-block(int block-type)
{
    loop
        get-next-word
        if word-is-end-of-block(block-type)
            return
        else if word-is-start-of-block
            find-end-of-block(...)   // recursive call
        end if
    end loop
}

get-next-word would handle skipping comments.  You could use the above code for a "find-matching-perenthesis" mechanism too.

Graeme

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2860
  • Hero Points: 434
Re: select-code-block for Ada?
« Reply #2 on: October 25, 2006, 03:38:57 pm »
Sure, all you have to do is implement the "selectCodeBlock_ada()" Slick-C hook function.  Look at "selectCodeBlock_cob()" for an example.