/********************************************************************
                         tabsize

   Description: Sets tab size to n
   Syntax:      tabsize [n]

               n - Specifies new tab size

  This script can be useful if you need to change tab size frequently

  To map this script to a shortcut key:

  1. Save this script in the GwdTextEditor\script directory.
  2. From the Macro menu, choose Macro command.
  3. Choose the New button.
  4. In the New Macro Name input box, type a name for the macro. For
     example Script_TabSize_8. In this dialog you can also define a
     shortcut key for this macro (eg. Ctrl 8).
  5. Choose the OK button.
  6. In the Edit Macro dialog box edit box enter the following two
     lines:
        Param1 "backtab.c 8"
        ExecScript
  7. Choose the Close button.
  8. You can now define shortcut key for Script_TabSize_8 macro
     in the Key Mapping dialog box.

 Author: Vedran Gaco.
********************************************************************/

#include <windows.h>
#include <stdlib.h>
#include <editor/options.h>
#include <editor/dlg.h>

/*-------------------------------------------------------------------
                    main function
-------------------------------------------------------------------*/

int main(int argc, char *argv[])
{
   int nNewTabSize;

   // if user didn't specify tab size in the command line, ask it
   if(argc < 2)
   {
      nNewTabSize = Gte_GetTabSize();
      if(Gte_GetIntDlg("Tab Size", "&Tab size:", 2, 16, &nNewTabSize) == FALSE)
         return 0;
   }
   else
   {
      nNewTabSize = atoi(argv[1]);
      if(nNewTabSize < 2 || nNewTabSize > 16)
      {
         MsgBox("Invalid tab size", MB_OK);
         return 1;
      }
   }
   // set new tab size
   Gte_SetTabSize(nNewTabSize);

   return 0;
}

