File: testselect.c

package info (click to toggle)
gedit 0.5.4-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 2,388 kB
  • ctags: 1,622
  • sloc: ansic: 10,760; sh: 4,975; makefile: 463; sed: 93
file content (32 lines) | stat: -rw-r--r-- 745 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdio.h>
#include "client.h"

int main (int argc, char *argv[])
{
	client_info info = empty_info;
	selection_range range;
	int docid, contextid, pos;
	char *text;

	info.menu_location = "[Plugins]Test Selection";

	contextid = client_init (&argc, &argv, &info);
	docid = client_document_current (contextid);

	pos = client_document_get_position (docid);
	printf ("Cursor is at position %i\n", pos);

	range = client_document_get_selection_range (docid);
	printf ("Selection starts at point %i, and ends at point %i\n", range.start, range.end);

	text = client_text_get_selection_text (docid);
	if (text == NULL)
		printf ("No text selected.\n");
	else
		printf ("\"%s\" selected\n", text);

	client_finish( contextid );

	exit (0);
}