Apply patch (with minor changes) from Jason Oster to improve showing

brace indent guides on empty lines when appropriate (thanks,
#2105982).


git-svn-id: https://geany.svn.sourceforge.net/svnroot/geany/trunk@2958 ea778897-0a13-0410-b9d1-a72fbfd435f5
This commit is contained in:
Nick Treleaven 2008-09-17 12:36:04 +00:00
parent a01abd937d
commit d625394615
3 changed files with 48 additions and 3 deletions

View File

@ -3,6 +3,10 @@
* src/callbacks.c, THANKS:
Cancel autocompletion on Undo/Redo (based on a patch by Jason Oster,
thanks; #2102715).
* src/sciwrappers.c, src/document.c:
Apply patch (with minor changes) from Jason Oster to improve showing
brace indent guides on empty lines when appropriate (thanks,
#2105982).
2008-09-16 Nick Treleaven <nick(dot)treleaven(at)btinternet(dot)com>

View File

@ -2167,6 +2167,7 @@ void document_set_filetype(GeanyDocument *doc, GeanyFiletype *type)
doc->tm_file = NULL;
}
highlighting_set_styles(doc->editor->sci, type->id);
sci_set_indentation_guides(doc->editor->sci, editor_prefs.show_indent_guide);
build_menu_update(doc);
queue_colourise(doc);
}

View File

@ -32,6 +32,7 @@
#include "geany.h"
#include "SciLexer.h"
#include "sciwrappers.h"
#include "utils.h"
@ -373,7 +374,7 @@ gint sci_marker_previous(ScintillaObject* sci, gint line, gint marker_mask, gboo
/** Get line number from position.
* @param sci Scintilla widget.
* @param position Position. */
* @param position Position. */
gint sci_get_line_from_position(ScintillaObject* sci, gint position )
{
return SSM(sci, SCI_LINEFROMPOSITION, position, 0);
@ -382,7 +383,7 @@ gint sci_get_line_from_position(ScintillaObject* sci, gint position )
/** Get column number relative to the start of the line that @a position is on.
* @param sci Scintilla widget.
* @param position Position. */
* @param position Position. */
gint sci_get_col_from_position(ScintillaObject* sci, gint position )
{
return SSM(sci, SCI_GETCOLUMN, position, 0);
@ -706,10 +707,49 @@ void sci_set_savepoint(ScintillaObject *sci)
SSM(sci, SCI_SETSAVEPOINT, 0, 0);
}
/* Should these be user-defined instead of hard-coded? */
static gint get_indent_guides_from_lexer(gint lexer)
{
switch (lexer)
{
/* These languages use indentation for control blocks; the "look forward" method works best here */
case SCLEX_PYTHON:
case SCLEX_HASKELL:
case SCLEX_MAKEFILE:
case SCLEX_ASM:
case SCLEX_SQL:
case SCLEX_PROPERTIES:
case SCLEX_FORTRAN: /* Is this the best option for Fortran? */
case SCLEX_CAML:
return SC_IV_LOOKFORWARD;
/* C-like (structured) languages benefit from the "look both" method */
case SCLEX_CPP:
case SCLEX_HTML:
case SCLEX_XML:
case SCLEX_PERL:
case SCLEX_LATEX:
case SCLEX_LUA:
case SCLEX_PASCAL:
case SCLEX_RUBY:
case SCLEX_TCL:
case SCLEX_F77:
case SCLEX_CSS:
case SCLEX_BASH:
case SCLEX_VHDL:
case SCLEX_FREEBASIC:
case SCLEX_D:
case SCLEX_OMS:
return SC_IV_LOOKBOTH;
}
return SC_IV_REAL;
}
void sci_set_indentation_guides(ScintillaObject *sci, gboolean enable)
{
SSM(sci, SCI_SETINDENTATIONGUIDES, enable, 0);
gint lexer = sci_get_lexer(sci);
SSM(sci, SCI_SETINDENTATIONGUIDES, (enable ? get_indent_guides_from_lexer(lexer) : SC_IV_NONE), 0);
}