~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): Gauvain Pocentek
  • Date: 2008-05-09 20:40:06 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080509204006-9fu737rfvapfj7pn
Tags: 0.14-1ubuntu1
* Merge from debian unstable, remaining changes:
  - patches/20_add_debdiff_as_diff_type.dpatch:
    Also recognize .dpatch files as diff's
  - debian/geany.xpm:
    Replace icon with a .xpm of the new one
  - Modify Maintainer value to match the DebianMaintainerField
    specification.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *      along with this program; if not, write to the Free Software
18
18
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
 *
20
 
 * $Id: sciwrappers.c 2150 2008-01-06 18:11:57Z eht16 $
 
20
 * $Id: sciwrappers.c 2312 2008-03-07 15:42:46Z eht16 $
21
21
 */
22
22
 
23
23
/*
35
35
#define SSM(s, m, w, l) scintilla_send_message(s, m, w, l)
36
36
 
37
37
 
38
 
// stolen from cssed (http://cssed.sf.net), thanks
 
38
/* stolen from cssed (http://cssed.sf.net), thanks */
39
39
 
40
40
 
41
41
/* line numbers visibility */
49
49
                g_snprintf(tmp_str, 15, "_%d%d", len, extra_width);
50
50
                width = SSM(sci, SCI_TEXTWIDTH, STYLE_LINENUMBER, (sptr_t) tmp_str);
51
51
                SSM (sci, SCI_SETMARGINWIDTHN, 0, width);
52
 
                SSM (sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); // use default behaviour
 
52
                SSM (sci, SCI_SETMARGINSENSITIVEN, 0, FALSE); /* use default behaviour */
53
53
        }
54
54
        else
55
55
        {
78
78
                        return;
79
79
                }
80
80
        }
81
 
        SSM(sci, SCI_SETEDGECOLUMN, column - 1, 0);
 
81
        SSM(sci, SCI_SETEDGECOLUMN, column, 0);
82
82
        SSM(sci, SCI_SETEDGECOLOUR, utils_strtod(colour, NULL, TRUE), 0);
83
83
}
84
84
 
164
164
void sci_set_lines_wrapped(ScintillaObject* sci, gboolean set )
165
165
{
166
166
        if (set)
167
 
        {
168
167
                SSM(sci,SCI_SETWRAPMODE,SC_WRAP_WORD,0);
169
 
                SSM(sci, SCI_SETWRAPVISUALFLAGS, SC_WRAPVISUALFLAG_END | SC_WRAPVISUALFLAG_START, 0);
170
 
        }
171
168
        else
172
169
                SSM(sci,SCI_SETWRAPMODE,SC_WRAP_NONE,0);
173
170
}
194
191
 
195
192
void sci_add_text(ScintillaObject* sci, const gchar* text)
196
193
{
197
 
        if( text != NULL ){// if null text is passed to scintilla will segfault
 
194
        if( text != NULL ){ /* if null text is passed to scintilla will segfault */
198
195
                SSM( sci, SCI_ADDTEXT, strlen(text), (sptr_t) text);
199
196
        }
200
197
}
201
198
 
202
199
void sci_set_text(ScintillaObject* sci, const gchar* text)
203
200
{
204
 
        if( text != NULL ){// if null text is passed to scintilla will segfault
 
201
        if( text != NULL ){ /* if null text is passed to scintilla will segfault */
205
202
                SSM( sci, SCI_SETTEXT, 0, (sptr_t) text);
206
203
        }
207
204
}
209
206
 
210
207
void sci_add_text_buffer(ScintillaObject* sci, const gchar* text, gint len)
211
208
{
212
 
        if( text != NULL ){// if null text is passed to scintilla will segfault
 
209
        if( text != NULL ){ /* if null text is passed to scintilla will segfault */
213
210
                SSM(sci, SCI_CLEARALL, 0, 0);
214
211
                SSM(sci, SCI_ADDTEXT, len, (sptr_t) text);
215
212
        }
233
230
        if( sci_can_undo(sci) )
234
231
                SSM( sci, SCI_UNDO, 0, 0);
235
232
        else
236
 
        { // change it to a document function
 
233
        { /* change it to a document function */
237
234
 
238
235
        }
239
236
}
244
241
        if( sci_can_redo( sci ) )
245
242
                SSM( sci, SCI_REDO,0,0);
246
243
        else
247
 
        { // change it to a document function
 
244
        { /* change it to a document function */
248
245
 
249
246
        }
250
247
}
396
393
        else
397
394
        {
398
395
                SSM(sci, SCI_SETCURRENTPOS, position, 0);
399
 
                SSM(sci, SCI_SETANCHOR, position, 0); // to avoid creation of a selection
 
396
                SSM(sci, SCI_SETANCHOR, position, 0); /* to avoid creation of a selection */
400
397
        }
 
398
        SSM(sci, SCI_CHOOSECARETX, 0, 0);
401
399
}
402
400
 
403
401
 
404
 
void sci_set_current_line(ScintillaObject* sci, gint line )
 
402
/* Set the cursor line without scrolling the view.
 
403
 * Use sci_goto_line() to also scroll. */
 
404
void sci_set_current_line(ScintillaObject* sci, gint line)
405
405
{
406
 
        SSM(sci, SCI_GOTOLINE, line, 0);
 
406
        gint pos = sci_get_position_from_line(sci, line);
 
407
        sci_set_current_position(sci, pos, FALSE);
407
408
}
408
409
 
409
410
 
491
492
}
492
493
 
493
494
 
494
 
// Returns: a NULL-terminated copy of the line text
 
495
/* Returns: a NULL-terminated copy of the line text */
495
496
gchar *sci_get_line(ScintillaObject* sci, gint line_num)
496
497
{
497
498
        gint len = sci_get_line_length(sci, line_num);
503
504
}
504
505
 
505
506
 
506
 
// the last char will be null terminated
 
507
/* the last char will be null terminated */
507
508
void sci_get_text(ScintillaObject* sci, gint len, gchar* text)
508
509
{
509
510
        SSM( sci, SCI_GETTEXT, len, (sptr_t) text );
526
527
 
527
528
gint sci_get_position_from_xy(ScintillaObject* sci, gint x, gint y, gboolean nearby)
528
529
{
529
 
        // for nearby return -1 if there is no character near to the x,y point.
 
530
        /* for nearby return -1 if there is no character near to the x,y point. */
530
531
        return SSM(sci, (nearby) ? SCI_POSITIONFROMPOINTCLOSE : SCI_POSITIONFROMPOINT, x, y);
531
532
}
532
533
 
643
644
}
644
645
 
645
646
 
646
 
// you can also call this has_selection
 
647
/* you can also call this has_selection */
647
648
gboolean sci_can_copy(ScintillaObject *sci)
648
649
{
649
650
        if (SSM(sci, SCI_GETSELECTIONEND,0,0) - SSM(sci, SCI_GETSELECTIONSTART,0,0))
807
808
 
808
809
gint sci_target_replace(ScintillaObject *sci, const gchar *text, gboolean regex)
809
810
{
810
 
        return SSM(sci, (regex) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET, -1, (sptr_t) text);
 
811
        return SSM(sci, (regex) ? SCI_REPLACETARGETRE : SCI_REPLACETARGET, (uptr_t) -1, (sptr_t) text);
811
812
}
812
813
 
813
814
 
826
827
        return SSM(sci, SCI_GETREADONLY, 0, 0);
827
828
}
828
829
 
829
 
// a simple convenience function to not have SSM() in the outside of this file
 
830
/* a simple convenience function to not have SSM() in the outside of this file */
830
831
 void sci_cmd(ScintillaObject * sci, gint cmd)
831
832
{
832
833
        SSM(sci, cmd, 0, 0);
847
848
        gint end = SSM(sci, SCI_GETSELECTIONEND, 0, 0);
848
849
 
849
850
        if (start == end)
850
 
                return 0; // no selection
 
851
                return 0; /* no selection */
851
852
 
852
853
        return SSM(sci, SCI_LINEFROMPOSITION, end, 0) - SSM(sci, SCI_LINEFROMPOSITION, start, 0) + 1;
853
854
}