1 /*
2  * Copyright 2018 Jiri Techet <techet@gmail.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "cmd-params.h"
20 
cmd_params_init(CmdParams * param,ScintillaObject * sci,gint num,gboolean num_present,GSList * kpl,gboolean is_operator_cmd,gint sel_start,gint sel_len)21 void cmd_params_init(CmdParams *param, ScintillaObject *sci,
22 	gint num, gboolean num_present, GSList *kpl, gboolean is_operator_cmd,
23 	gint sel_start, gint sel_len)
24 {
25 	param->sci = sci;
26 
27 	param->num = num;
28 	param->num_present = num_present;
29 	param->last_kp = kpl != NULL ? g_slist_nth_data(kpl, 0) : NULL;
30 	param->is_operator_cmd = is_operator_cmd;
31 
32 	param->sel_start = sel_start;
33 	param->sel_len = sel_len;
34 	param->sel_first_line = SSM(sci, SCI_LINEFROMPOSITION, sel_start, 0);
35 	param->sel_first_line_begin_pos = SSM(sci, SCI_POSITIONFROMLINE, param->sel_first_line, 0);
36 	param->sel_last_line = SSM(sci, SCI_LINEFROMPOSITION, sel_start + sel_len, 0);
37 	param->sel_last_line_end_pos = SSM(sci, SCI_GETLINEENDPOSITION, param->sel_last_line, 0);
38 
39 	param->pos = SSM(sci, SCI_GETCURRENTPOS, 0, 0);
40 	param->line = GET_CUR_LINE(sci);
41 	param->line_end_pos = SSM(sci, SCI_GETLINEENDPOSITION, param->line, 0);
42 	param->line_start_pos = SSM(sci, SCI_POSITIONFROMLINE, param->line, 0);
43 	param->line_num = SSM(sci, SCI_GETLINECOUNT, 0, 0);
44 	param->line_visible_first = SSM(sci, SCI_GETFIRSTVISIBLELINE, 0, 0);
45 	param->line_visible_num = SSM(sci, SCI_LINESONSCREEN, 0, 0);
46 }
47