IupScintillaDlg (since 3.22)

Creates a notepad dialog using the IupScintilla control. It is a predefined dialog for a text notepad. The dialog can be shown with IupShow, IupShowXY or IupPopup.

Creation

Ihandle* IupScintillaDlg(void); [in C]
iup.scintilladlg{} -> (elem: ihandle) [in Lua]
scintilladlg() [in LED]

Returns: the identifier of the created element, or NULL if an error occurs.

Attributes

Supports all the IupDialog attributes. But some attributes where changed to configure the dialog and the dialog has innumerous children to compose the notepad.


New attributes. All non inheritable.

SUBTITLE: partial title to be used in dialog title along with the current file name title.

CONFIG: name of a IupConfig resource to be used for persistency of menu options and recent file list. Must be set before map.

CONFIG_HANDLE: Ihandle of the IupConfig resource.

NEWFILE (write-only): clear the text contents and initialize a new file.

OPENFILE (write-only): opens a file using the value as filename. If value is NULL works as NEWFILE.

SAVEFILE (write-only): saves a file using the value as filename. If value is NULL uses the current file name.

EXTRAFILTERS: additional filters for File Open and File Save As dialogs in the same format as the IupFileDlg EXTFILTER attribute. The filters will be concatenated at start with the existing filters: "Text Files|*.txt|All Files|*.*|".

TOGGLEMARKERid (write-only): toggles the state of a marker given its line number as id, and margin as value.

Callbacks

Supports all the IupDialog callbacks.


New callbacks.

MARKERCHANGED_CB: Action generated when a marker is changed in a margin (interactively or programmatically).

int function(Ihandle* ih, int lin, int margin); [in C]
elem:markerchanged_cb(lin, margin: number) -> (ret: number) [in Lua]

ih: identifier of the element that activated the event.
lin: line number where the marker was changed (starts at 0).
margin: which margin was affected.

Notes

The dialog can be freely customized to incorporate other menu items or controls.

The dialog explores many IupScintilla features and made them available through the menus. The screenshots bellow illustrates some of them.

Examples

static int item_help_action_cb(void)
{
  IupHelp("http://www.tecgraf.puc-rio.br/iup");
  return IUP_DEFAULT;
}

static int item_about_action_cb(void)
{
  IupMessage("About", "   Scintilla Notepad\n\nAutors:\n   Camilo Freire\n   Antonio Scuri");
  return IUP_DEFAULT;
}

int main(int argc, char **argv)
{
  Ihandle *main_dialog;
  Ihandle *config;
  Ihandle *menu;

  IupOpen(&argc, &argv);
  IupImageLibOpen();

  IupScintillaOpen();

  config = IupConfig();
  IupSetAttribute(config, "APP_NAME", "scintilla_notepad");
  IupConfigLoad(config);

  main_dialog = IupScintillaDlg();

  IupSetAttributeHandle(main_dialog, "CONFIG", config);
  IupSetAttribute(main_dialog, "SUBTITLE", "Scintilla Notepad");

  menu = IupGetAttributeHandle(main_dialog, "MENU");
  IupAppend(menu, IupSubmenu("&Help", IupMenu(
    IupSetCallbacks(IupItem("&Help...", NULL), "ACTION", (Icallback)item_help_action_cb, NULL),
    IupSetCallbacks(IupItem("&About...", NULL), "ACTION", (Icallback)item_about_action_cb, NULL),
    NULL)));

  /* show the dialog at the last position, with the last size */
  IupConfigDialogShow(config, main_dialog, "MainWindow");

  /* initialize the current file */
  IupSetAttribute(main_dialog, "NEWFILE", NULL);

  /* open a file from the command line (allow file association in Windows) */
  if (argc > 1 && argv[1])
  {
    const char* filename = argv[1];
    IupSetStrAttribute(main_dialog, "OPENFILE", filename);
  }

  IupMainLoop();

  IupClose();
  return EXIT_SUCCESS;
}

View menu and dialog overview

Edit menu

Blank Operations

See Also

IupScintilla, IupDialog