Towards Supporting Blocks When Editing GETS

Towards Supporting Blocks When Editing GETS

Postby xProgrammer » Fri May 16, 2008 2:41 pm

Hi Antonio

Thanks for your help, I'm underway but have to get some sleep now.

I now have a working GETGETSEL as follows:

Code: Select all  Expand view
HB_FUNC( GETGETSEL )
{
   gboolean retval;
   gint start;
   gint end;
   GtkWidget * hWnd = ( GtkWidget * ) hb_parnl( 1 );
   retval = gtk_editable_get_selection_bounds( GTK_EDITABLE( hWnd ),   &start,  &end );
   hb_stornl( start, 2 );
   hb_stornl( end, 3 );
   hb_retl( retval );
}


in gets.c and

Code: Select all  Expand view
METHOD GetSel( nStart, nEnd ) CLASS TGet

   LOCAL iFirst
   LOCAL iLast
   LOCAL lRetVal

   iFirst := 0
   iLast  := 0
   lRetVal := GetGetSel( ::hWnd, @iFirst, @iLast )
   IF lRetVal
      // MsgInfo( "Selection" )
      // MsgInfo( iFirst )
      // MsgInfo( iLast )
      nStart := iFirst
      nEnd := iLast
   ENDIF

RETURN lRetVal


in get.prg

nStart is set to first character in selection (0 based) and nEnd to the first character not in the selection (0 based).

It may be convenient to modify these values, perhaps to give first character position (1 based) and length depending upon the best way to modify TGet:KeyDown().

Thanks
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Fri May 16, 2008 5:09 pm

Doug,

You are improving your C coding and Harbour extended API management very much :-)

I guess that you want to know the selected GET block, to replace it with a pressed key. Is it so ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby xProgrammer » Sat May 17, 2008 4:18 am

Thanks Antonio

I will write the necessary code to adjust the contents of (xHarbour) get object - I stopped where I did last night because it was 1:00 am and my wife said I had to go to bed.

Must be getting on for 10 years since I last wrote any even slightly serious code in C.

I'll rewrite the .prg code more in your style - I have my own style pretty much ingrained from years of writing dBase then Clipper code. (That stopped even longer ago I think )Though it has been "polluted" a bit by having to write Visual Basic (hate the language), HTML, XML, SQL, Java Script. So now I'm not 100% consistent. Mind you the language now presents new challenges / opportunities style wise, not the least of which is OO support. Norms seem to have changed over the years. When I started out dBase keywords and (inbuilt) functions were all capitals and user defined functions were initial capital letters only. Now people write "if" and "endif" and that seems to be the new norm.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby xProgrammer » Mon May 19, 2008 12:02 pm

Hi Antonio

Have had problems with NFS with Ubuntu 8.04 (32 and 64 bit) just resolved.

Just started modifying get.prg to support blocked text. Have only written code so far to handle characters being added - del and backspace cases will also require modification.

Only just finished but seems to work properly.

Changes are:

added following local variables

Code: Select all  Expand view
   local lActiveBlock
   local nBlockStart
   local nBlockEnd
   local ii


added following statement immediately before the case statement:

Code: Select all  Expand view
   lActiveBlock := ::GetSel( @nBlockStart, @nBlockEnd )


added the following code immediately after the otherwise statement:

Code: Select all  Expand view
           if lActiveBlock
              ::oGet:home()
              for ii = 1 to nBlockStart
                 ::oGet:right()
              next
              for ii = 1 to ( nBlockEnd - nBlockStart )
                 ::oGet:delete()
              next
           endif


It may be better to make nBlockStart, nBlockEnd and lActiveBlock properties (DATAs) of class TGet and add a TGet:DeleteActiveBlock() method since this code may be required for both the del and backspace cases. I will look at those two cases as soon as I can but its bed time now and I have some very full days (and I suspect nights) ahead of me.

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby xProgrammer » Mon May 19, 2008 9:57 pm

Hi Antonio

Have finished modifications to get.prg to support block editing. I will email you the modified code.

I have tried to put comments around all my modifications / additions which makes it a bit messy in a way, but hopefully makes it easier to see what I have done.

My code includes modifications which you may or may not be interested in. The modifications are:

1. Support for block editing of text
2. Centralise resetting of text in the associated GTKEntry object
3. Support for codeblocks for Tab and Shift-Tab keys to enable tab order control
4. Support optional black text in non-editable mode (so it is easier to read). Different background colors make editable and non-editable items still easy to read.

I will also email my gets.c with the added GETGETSEL() function.

In order to use the black option you will also need my window.prg, windows.c and FiveLinuxDF.ch

Regards
Doug
(xProgrammer)
User avatar
xProgrammer
 
Posts: 464
Joined: Tue May 16, 2006 7:47 am
Location: Australia

Postby Antonio Linares » Tue May 20, 2008 10:59 am

Doug,

Many thanks! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42099
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain


Return to FiveLinux / FiveDroid (Android)

Who is online

Users browsing this forum: No registered users and 10 guests