Example #1
0
void tab_sql_set_lexer(Document *document)
{
  Preferences_Manager *prefmg = preferences_manager_new ();
  GtkScintilla *scintilla = document_get_scintilla(document);
  gtk_scintilla_clear_document_style (scintilla);
  gtk_scintilla_set_lexer(scintilla, SCLEX_SQL);
  gtk_scintilla_set_style_bits(scintilla, 5);

  gchar *font =NULL;
  gint size, fore, back;
  gboolean italic, bold;

  get_preferences_manager_style_settings(prefmg, "c_default", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_font (scintilla,  SCE_C_DEFAULT, font);
  gtk_scintilla_style_set_fore (scintilla,  SCE_C_DEFAULT, fore);
  gtk_scintilla_style_set_back (scintilla,  SCE_C_DEFAULT, back);
  gtk_scintilla_style_set_size (scintilla,  SCE_C_DEFAULT, size);
  gtk_scintilla_style_set_italic (scintilla,  SCE_C_DEFAULT, italic);
  gtk_scintilla_style_set_bold (scintilla,  SCE_C_DEFAULT, bold);

  get_preferences_manager_style_settings(prefmg, "php_default", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_font (scintilla,  STYLE_BRACELIGHT, font);
  gtk_scintilla_style_set_fore (scintilla,  STYLE_BRACELIGHT, 16711680);// Matching bracket
  if(get_preferences_manager_higthlight_caret_line (prefmg))
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACELIGHT, get_preferences_manager_higthlight_caret_line_color(prefmg));
  else
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACELIGHT, back);
  gtk_scintilla_style_set_size (scintilla,  STYLE_BRACELIGHT, size);
  gtk_scintilla_style_set_italic (scintilla,  STYLE_BRACELIGHT, italic);
  gtk_scintilla_style_set_bold (scintilla,  STYLE_BRACELIGHT, TRUE);
  gtk_scintilla_style_set_font (scintilla,  STYLE_BRACEBAD, font);
  gtk_scintilla_style_set_fore (scintilla,  STYLE_BRACEBAD, 255);
  if(get_preferences_manager_higthlight_caret_line (prefmg))
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACEBAD, get_preferences_manager_higthlight_caret_line_color(prefmg));
  else
    gtk_scintilla_style_set_back (scintilla,  STYLE_BRACEBAD, back);
  gtk_scintilla_style_set_size (scintilla,  STYLE_BRACEBAD, size);
  gtk_scintilla_style_set_italic (scintilla,  STYLE_BRACEBAD, italic);
  gtk_scintilla_style_set_bold (scintilla,  STYLE_BRACEBAD, TRUE);

  gtk_scintilla_set_keywords(scintilla, 0, "ADD ALL ALTER ANALYZE AND AS ASC ASENSITIVE AUTO_INCREMENT BDB BEFORE BERKELEYDB BETWEEN BIGINT BINARY BLOB BOTH BTREE BY CALL CASCADE CASE CHANGE CHAR CHARACTER CHECK COLLATE COLUMN COLUMNS CONNECTION CONSTRAINT CREATE CROSS CURRENT_DATE CURRENT_TIME CURRENT_TIMESTAMP CURSOR DATABASE DATABASES DAY_HOUR DAY_MINUTE DAY_SECOND DEC DECIMAL DECLARE DEFAULT DELAYED DELETE DESC DESCRIBE DISTINCT DISTINCTROW DIV DOUBLE DROP ELSE ELSEIF ENCLOSED ERRORS ESCAPED EXISTS EXPLAIN FALSE FIELDS FLOAT FOR FORCE FOREIGN FROM FULLTEXT GRANT GROUP HASH HAVING HIGH_PRIORITY HOUR_MINUTE HOUR_SECOND IF IGNORE IN INDEX INFILE INNER INNODB INOUT INSENSITIVE INSERT INT INTEGER INTERVAL INTO IS ITERATE JOIN KEY KEYS KILL LEADING LEAVE LEFT LIKE LIMIT LINES LOAD LOCALTIME LOCALTIMESTAMP LOCK LONG LONGBLOB LONGTEXT LOOP LOW_PRIORITY MASTER_SERVER_ID MATCH MEDIUMBLOB MEDIUMINT MEDIUMTEXT MIDDLEINT MINUTE_SECOND MOD MRG_MYISAM NATURAL NOT NULL NUMERIC ON OPTIMIZE OPTION OPTIONALLY OR ORDER OUT OUTER OUTFILE PRECISION PRIMARY PRIVILEGES PROCEDURE PURGE READ REAL REFERENCES REGEXP RENAME REPEAT REPLACE REQUIRE RESTRICT RETURN RETURNS REVOKE RIGHT RLIKE RTREE SELECT SENSITIVE SEPARATOR SET SHOW SMALLINT SOME SONAME SPATIAL SPECIFIC SQL_BIG_RESULT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT SSL STARTING STRAIGHT_JOIN STRIPED TABLE TABLES TERMINATED THEN TINYBLOB TINYINT TINYTEXT TO TRAILING TRUE TYPES UNION UNIQUE UNLOCK UNSIGNED UNTIL UPDATE USAGE USE USER_RESOURCES USING VALUES VARBINARY VARCHAR VARCHARACTER VARYING WARNINGS WHEN WHERE WHILE WITH WRITE XOR YEAR_MONTH ZEROFILL");

  get_preferences_manager_style_settings(prefmg, "sql_word", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_back (scintilla, SCE_C_WORD, back);
  gtk_scintilla_style_set_font (scintilla, SCE_C_WORD, font);
  gtk_scintilla_style_set_fore (scintilla, SCE_C_WORD, fore);
  gtk_scintilla_style_set_size (scintilla, SCE_C_WORD, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_WORD, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_WORD, bold);

  get_preferences_manager_style_settings(prefmg, "sql_string", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_STRING, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_STRING, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_STRING, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_STRING, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_STRING, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_STRING, bold);

  get_preferences_manager_style_settings(prefmg, "sql_operator", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_OPERATOR, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_OPERATOR, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_OPERATOR, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_OPERATOR, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_OPERATOR, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_OPERATOR, bold);

  get_preferences_manager_style_settings(prefmg, "sql_comment", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_COMMENT, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_COMMENT, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_COMMENT, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_COMMENT, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_COMMENT, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_COMMENT, bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_COMMENTLINE, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_COMMENTLINE, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_COMMENTLINE, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_COMMENTLINE, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_COMMENTLINE, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_COMMENTLINE, bold);

  get_preferences_manager_style_settings(prefmg, "sql_number", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_NUMBER, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_NUMBER, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_NUMBER, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_NUMBER, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_NUMBER, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_NUMBER, bold);

  get_preferences_manager_style_settings(prefmg, "sql_identifier", &font , &size, &fore, &back, &italic, &bold);

  gtk_scintilla_style_set_fore (scintilla, SCE_C_IDENTIFIER, fore);
  gtk_scintilla_style_set_font (scintilla, SCE_C_IDENTIFIER, font);
  gtk_scintilla_style_set_back (scintilla, SCE_C_IDENTIFIER, back);
  gtk_scintilla_style_set_size (scintilla, SCE_C_IDENTIFIER, size);
  gtk_scintilla_style_set_italic (scintilla, SCE_C_IDENTIFIER, italic);
  gtk_scintilla_style_set_bold (scintilla, SCE_C_IDENTIFIER, bold);

  gtk_scintilla_colourise(scintilla, 0, -1);
  g_object_unref(prefmg);
}
Example #2
0
void scintilla_python_set_lexer(GtkScintilla *scintilla, Preferences prefs)
{
	gtk_scintilla_clear_document_style (scintilla);
	// Don't know why - but it doesn't highlight if the next line is SCLEX_PYTHON
	gtk_scintilla_set_lexer(scintilla, SCLEX_PERL);
	gtk_scintilla_set_style_bits(scintilla, 5);

	/* Example style setting up code! */
    gtk_scintilla_autoc_set_choose_single (scintilla, TRUE);
    gtk_scintilla_set_use_tabs (scintilla, 1);
    gtk_scintilla_set_tab_indents (scintilla, 1);
    gtk_scintilla_set_backspace_unindents (scintilla, 1);
	gtk_scintilla_set_tab_width (scintilla, prefs.indentation_size);
    gtk_scintilla_set_indent (scintilla, prefs.tab_size);

    gtk_scintilla_style_set_font (scintilla, STYLE_DEFAULT, prefs.default_font);
    gtk_scintilla_style_set_size (scintilla, STYLE_DEFAULT, prefs.default_size);
    gtk_scintilla_style_set_italic (scintilla, STYLE_DEFAULT, prefs.default_italic);
    gtk_scintilla_style_set_bold (scintilla, STYLE_DEFAULT, prefs.default_bold);
    gtk_scintilla_style_set_fore (scintilla, STYLE_DEFAULT, prefs.default_fore);
    gtk_scintilla_style_set_back (scintilla, STYLE_DEFAULT, prefs.default_back);

    gtk_scintilla_style_set_font (scintilla, SCE_P_DEFAULT, prefs.php_default_font);
    gtk_scintilla_style_set_fore (scintilla, SCE_P_DEFAULT, prefs.php_default_fore);
    gtk_scintilla_style_set_back (scintilla, SCE_P_DEFAULT, prefs.php_default_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_DEFAULT, prefs.php_default_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_DEFAULT, prefs.php_default_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_DEFAULT, prefs.php_default_bold);

	//gtk_scintilla_set_sel_back (GTK_SCINTILLA(editor->scintilla), TRUE, prefs.set_sel_back);
    //gtk_scintilla_marker_set_back (GTK_SCINTILLA(editor->scintilla), TRUE, prefs.marker_back);

    gtk_scintilla_set_caret_fore (scintilla, 0);
    gtk_scintilla_set_caret_width (scintilla, 2);
    gtk_scintilla_set_caret_period (scintilla, 250);

    gtk_scintilla_style_set_font (scintilla, STYLE_BRACELIGHT, prefs.php_default_font);
    gtk_scintilla_style_set_fore (scintilla, STYLE_BRACELIGHT, 16711680);// Matching bracket
    gtk_scintilla_style_set_back (scintilla, STYLE_BRACELIGHT, prefs.php_default_back);
    gtk_scintilla_style_set_size (scintilla, STYLE_BRACELIGHT, prefs.php_default_size);
    gtk_scintilla_style_set_italic (scintilla, STYLE_BRACELIGHT, prefs.php_default_italic);
    gtk_scintilla_style_set_bold (scintilla, STYLE_BRACELIGHT, TRUE);
    gtk_scintilla_style_set_font (scintilla, STYLE_BRACEBAD, prefs.php_default_font);
    gtk_scintilla_style_set_fore (scintilla, STYLE_BRACEBAD, 255);
    gtk_scintilla_style_set_back (scintilla, STYLE_BRACEBAD, prefs.php_default_back);
    gtk_scintilla_style_set_size (scintilla, STYLE_BRACEBAD, prefs.php_default_size);
    gtk_scintilla_style_set_italic (scintilla, STYLE_BRACEBAD, prefs.php_default_italic);
    gtk_scintilla_style_set_bold (scintilla, STYLE_BRACEBAD, TRUE);
	
    gtk_scintilla_set_indentation_guides (scintilla, prefs.show_indentation_guides);
    gtk_scintilla_set_edge_mode (scintilla, prefs.edge_mode);
    gtk_scintilla_set_edge_column (scintilla, prefs.edge_column);
    gtk_scintilla_set_edge_colour (scintilla, prefs.edge_colour);
	// Python keywords
	gtk_scintilla_set_keywords(scintilla, 0, "and assert break class continue def del elif else except exec finally for from global if import in is lambda None not or pass print raise return try while yield");
	
    gtk_scintilla_style_set_fore (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_TRIPLEDOUBLE, prefs.php_hstring_bold);
    gtk_scintilla_style_set_fore (scintilla, SCE_P_TRIPLE, prefs.php_hstring_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_TRIPLE, prefs.php_hstring_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_TRIPLE, prefs.php_hstring_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_TRIPLE, prefs.php_hstring_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_TRIPLE, prefs.php_hstring_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_TRIPLE, prefs.php_hstring_bold);
    
	gtk_scintilla_style_set_fore (scintilla, SCE_P_STRING, prefs.php_simplestring_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_STRING, prefs.php_simplestring_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_STRING, prefs.php_simplestring_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_STRING, prefs.php_simplestring_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_STRING, prefs.php_simplestring_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_STRING, prefs.php_simplestring_bold);
	gtk_scintilla_style_set_fore (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_CHARACTER, prefs.php_simplestring_bold);
	
    gtk_scintilla_style_set_font (scintilla, SCE_P_WORD, prefs.php_word_font);
	gtk_scintilla_style_set_fore (scintilla, SCE_P_WORD, prefs.php_word_fore);
    gtk_scintilla_style_set_back (scintilla, SCE_P_WORD, prefs.php_word_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_WORD, prefs.php_word_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_WORD, prefs.php_word_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_WORD, prefs.php_word_bold);

    gtk_scintilla_style_set_fore (scintilla, SCE_P_NUMBER, prefs.php_number_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_NUMBER, prefs.php_number_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_NUMBER, prefs.php_number_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_NUMBER, prefs.php_number_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_NUMBER, prefs.php_number_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_NUMBER, prefs.php_number_bold);

    gtk_scintilla_style_set_fore (scintilla, SCE_P_IDENTIFIER, prefs.php_default_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_IDENTIFIER, prefs.php_default_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_IDENTIFIER, prefs.php_default_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_IDENTIFIER, prefs.php_default_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_IDENTIFIER, prefs.php_default_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_IDENTIFIER, prefs.php_default_bold);

    gtk_scintilla_style_set_fore (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_fore);
    gtk_scintilla_style_set_font (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_font);
    gtk_scintilla_style_set_back (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_back);
    gtk_scintilla_style_set_size (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_size);
    gtk_scintilla_style_set_italic (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_italic);
    gtk_scintilla_style_set_bold (scintilla, SCE_P_COMMENTLINE, prefs.php_comment_line_bold);

	gtk_scintilla_set_property(scintilla, "fold", "1");
	gtk_scintilla_colourise(scintilla, 0, -1);
}