Author Topic: "Select mode" feature request  (Read 8717 times)

AllenR

  • Community Member
  • Posts: 11
  • Hero Points: 0
"Select mode" feature request
« on: August 21, 2007, 03:28:25 PM »
Would a “default mode” option on the Select Mode dialog box be useful to anyone (else)? 

I frequently access host files, that do not have extensions, via FTP and _getFileTypeFromSource is being used to determine the language type.  If I could set COBOL as the default mode, instead of fundamental, I would have to do Document > Select Mode… less frequently.

Another option is I could add additional tests and “line one” values to _getFileTypeFromSource and keep it updated as new versions of stdcmds.e come out.

A third option is for the development team to parameterize the tests in _getFileTypeFromSource so that a user configuration table holds values, starting positions, language type etc. so _getFileTypeFromSource is not as hard-coded as it currently is.

Your thoughts?

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: "Select mode" feature request
« Reply #1 on: August 21, 2007, 07:03:34 PM »
Sounds like a good idea.

As a simple solution you could make use of Slick's callback mechanism.

Sample vusrmacs.e:
Code: [Select]
#include "slick.sh"

_str def_edit_mode = 'cob';
void _buffer_add_editmode ( int bid, _str bname, int bflags)
{
   if ( p_mode_name :== 'Fundamental' )   select_edit_mode( def_edit_mode );
   // @see cmmode.e - userSelectEditMode()
}

// helper command for 'new-file' command - use '*' as arg to pick (document) mode from list
_command void nfe ( _str editmode = def_edit_mode ) name_info (WORD_ARG","VSARG2_CMDLINE|VSARG2_REQUIRES_MDI)
{
   // see new_file()
   _macro_delete_line();
   _str result='+t';
   _macro('m',_macro('s'));
   _macro_call('edit',result);
   p_window_id=_mdi._edit_window();
   if ( !edit(result) )
   {
      int index = 0;
      if ( editmode == '*' ) select_mode ( _ext2modename(editmode,index) );
      else select_edit_mode ( editmode );
   }
}

With 'set-var def_edit_mode <empty string>' (or 'Fundamental' of course) you get back the normal behaviour.
Seems that you could add user specific 'mode selection' in cmmode.e - userSelectEditMode() which is surely better than patching 'stdcmds.e'.

Edit: changed def_document_mode -> def_edit_mode

HS2
« Last Edit: August 21, 2007, 11:43:05 PM by hs2 »

Steve Black

  • Community Member
  • Posts: 57
  • Hero Points: 4
Re: "Select mode" feature request
« Reply #2 on: August 22, 2007, 02:20:21 PM »
Option 3 sounds like a winner to me.  Seems most in tune with the kind of flexibility that makes Slick so... slick.

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: "Select mode" feature request
« Reply #3 on: July 15, 2008, 12:21:48 PM »
hs2

Thanks for the function i am now using it

ehab

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: "Select mode" feature request
« Reply #4 on: July 20, 2008, 10:47:44 PM »
Thanks to ehab I fixed a problem with the 'nfe' macro. Now the configured encoding (per language/global default) is taken into account when the new buffer is created.
Have fun, HS2

PS: I had to attach the macro b/c post failed.

Edit: Updated attachment with some comment improvements.
« Last Edit: July 20, 2008, 11:11:01 PM by hs2 »

ehab

  • Senior Community Member
  • Posts: 285
  • Hero Points: 15
  • coding with SE is like playing music
Re: "Select mode" feature request
« Reply #5 on: July 20, 2008, 11:09:03 PM »

Respect Hs2 , thank you for your time and update , its sweet now : )

allah's blessings and may your week be fruitful

ehab