~ubuntu-branches/ubuntu/jaunty/geany/jaunty

« back to all changes in this revision

Viewing changes to src/sciwrappers.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc
  • Date: 2007-02-25 21:12:13 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20070225211213-jk4d4vxtgji0rj74
Tags: 0.10.2-0ubuntu1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *      sciwrappers.c - this file is part of Geany, a fast and lightweight IDE
3
3
 *
4
 
 *      Copyright 2006 Enrico Troeger <enrico.troeger@uvena.de>
 
4
 *      Copyright 2005-2007 Enrico Tröger <enrico.troeger@uvena.de>
 
5
 *      Copyright 2006-2007 Nick Treleaven <nick.treleaven@btinternet.com>
5
6
 *
6
7
 *      This program is free software; you can redistribute it and/or modify
7
8
 *      it under the terms of the GNU General Public License as published by
17
18
 *      along with this program; if not, write to the Free Software
18
19
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20
 *
20
 
 * $Id: sciwrappers.c 1120 2006-12-18 15:58:00Z ntrel $
 
21
 * $Id: sciwrappers.c 1270 2007-02-12 18:42:15Z eht16 $
21
22
 */
22
23
 
23
24
#include <string.h>
379
380
}
380
381
 
381
382
 
382
 
void sci_set_current_position(ScintillaObject* sci, gint position )
 
383
void sci_set_current_position(ScintillaObject* sci, gint position, gboolean scroll_to_caret)
383
384
{
384
 
        SSM(sci, SCI_GOTOPOS, position, 0);
 
385
        if (scroll_to_caret)
 
386
                SSM(sci, SCI_GOTOPOS, position, 0);
 
387
        else
 
388
        {
 
389
                SSM(sci, SCI_SETCURRENTPOS, position, 0);
 
390
                SSM(sci, SCI_SETANCHOR, position, 0); // to avoid creation of a selection
 
391
        }
385
392
}
386
393
 
387
394
 
672
679
}
673
680
 
674
681
 
675
 
/* Scroll the view to make line appear at percent_of_view.
676
 
 * line can be -1 to use the current position. */
677
 
void sci_scroll_to_line(ScintillaObject *sci, gint line, gfloat percent_of_view)
678
 
{
679
 
        gint vis1, los, delta;
680
 
 
681
 
        if (GTK_WIDGET(sci)->allocation.height <= 1) return;    // prevent gdk_window_scroll warning
682
 
        if (line == -1)
683
 
                line = sci_get_current_line(sci, -1);
684
 
 
685
 
        // sci 'visible line' != file line number
686
 
        vis1 = SSM(sci, SCI_GETFIRSTVISIBLELINE, 0, 0);
687
 
        vis1 = SSM(sci, SCI_DOCLINEFROMVISIBLE, vis1, 0);
688
 
        los = SSM(sci, SCI_LINESONSCREEN, 0, 0);
689
 
        delta = (line - vis1) - los * percent_of_view;
690
 
        sci_scroll_lines(sci, delta);
691
 
        sci_scroll_caret(sci); //ensure visible, in case of excessive folding/wrapping
692
 
}
693
 
 
694
 
 
695
682
gint sci_search_next(ScintillaObject *sci, gint flags, const gchar *text)
696
683
{
697
684
        return SSM(sci, SCI_SEARCHNEXT, flags, (sptr_t) text );
754
741
}
755
742
 
756
743
 
 
744
/* text will be zero terminated and must be allocated (end - start + 1) bytes */
757
745
void sci_get_text_range(ScintillaObject *sci, gint start, gint end, gchar *text)
758
746
{
759
747
        struct TextRange tr;