예제 #1
0
void ttext_box::update_canvas()
{
	/***** Gather the info *****/

	// Set the cursor info.
	const unsigned start = get_selection_start();
	const int length = get_selection_length();

	set_maximum_length(max_input_length_);

	PangoEllipsizeMode ellipse_mode = PANGO_ELLIPSIZE_NONE;
	if(!can_wrap()) {
		if((start + length) > (get_length() / 2)) {
			ellipse_mode = PANGO_ELLIPSIZE_START;
		} else {
			ellipse_mode = PANGO_ELLIPSIZE_END;
		}
	}
	set_ellipse_mode(ellipse_mode);

	// Set the selection info
	unsigned start_offset = 0;
	unsigned end_offset = 0;
	if(length == 0) {
		// No nothing.
	} else if(length > 0) {
		start_offset = get_cursor_position(start).x;
		end_offset = get_cursor_position(start + length).x;
	} else {
		start_offset = get_cursor_position(start + length).x;
		end_offset = get_cursor_position(start).x;
	}

	/***** Set in all canvases *****/

	const int max_width = get_text_maximum_width();
	const int max_height = get_text_maximum_height();

	for(auto & tmp : canvas())
	{

		tmp.set_variable("text", variant(get_value()));
		tmp.set_variable("text_x_offset", variant(text_x_offset_));
		tmp.set_variable("text_y_offset", variant(text_y_offset_));
		tmp.set_variable("text_maximum_width", variant(max_width));
		tmp.set_variable("text_maximum_height", variant(max_height));

		tmp.set_variable("cursor_offset",
						 variant(get_cursor_position(start + length).x));

		tmp.set_variable("selection_offset", variant(start_offset));
		tmp.set_variable("selection_width", variant(end_offset - start_offset));
		tmp.set_variable("text_wrap_mode", variant(ellipse_mode));
	}
}
/* DDS3.18: Update DEO Preference */
void update_deo_preference(unsigned int pref)
{
	struct cursor cursor;
	unsigned int group_index, dbci;
	int screen_candidate_index;
	const struct rotation *rotation;
	struct ballot_contents *ballot;

	cursor = get_cursor_position();
	group_index = cursor.group_index;
	screen_candidate_index = cursor.screen_candidate_index;
	/* If screen candidate index is -1 then cursor is on a group heading */
	if (screen_candidate_index > -1) {
		ballot = get_ballot_contents();
		rotation = get_current_rotation();
		/* SIPL 2011-06-28 Use updated translate function. */
		dbci = translate_group_sci_to_dbci
			(group_index,
			 screen_candidate_index,
			 rotation);
		insert_preference_digit(group_index, dbci, pref);
		/* Redraw the candidates preference box with the new 
		   preference number */
		draw_group_entry(cursor, YES, NO);
	}
}
예제 #3
0
gui2::tpoint ttext::get_column_line(const gui2::tpoint& position) const
{
	recalculate();

	// Get the index of the character.
	int index, trailing;
	pango_layout_xy_to_index(layout_, position.x * PANGO_SCALE,
		position.y * PANGO_SCALE, &index, &trailing);

	// Extract the line and the offset in pixels in that line.
	int line, offset;
	pango_layout_index_to_line_x(layout_, index, trailing, &line, &offset);
	offset = PANGO_PIXELS(offset);

	// Now convert this offset to a column, this way is a bit hacky but haven't
	// found a better solution yet.

	/**
	 * @todo There's still a bug left. When you select a text which is in the
	 * ellipses on the right side the text gets reformatted with ellipses on
	 * the left and the selected character is not the one under the cursor.
	 * Other widget toolkits don't show ellipses and have no indication more
	 * text is available. Haven't found what the best thing to do would be.
	 * Until that time leave it as is.
	 */
	for(size_t i = 0; ; ++i) {
		const int pos = get_cursor_position(i, line).x;

		if(pos == offset) {
			return  gui2::tpoint(i, line);
		}
	}
}
/* DDS3.14: Accumulate DEO Preferences */
bool accumulate_deo_preferences(void)
{
	bool paper_complete = false;
	enum deo_keystroke key;
	bool cancelled = false;
	
	draw_group_entry(get_cursor_position(),YES,false);
	while (!paper_complete) {
		key = interpret_deo_keystroke();
		if ((key == DEO_KEYSTROKE_DOWN) || (key == DEO_KEYSTROKE_UP) 
		    || (key == DEO_KEYSTROKE_NEXT)) {
			move_deo_cursor(key);
		}
		else if (key == DEO_KEYSTROKE_CANCEL_PAPER) {
			cancelled =  display_cancel_paper_screen();
			paper_complete = cancelled;
		}
		else if (key == DEO_KEYSTROKE_FINISH_PAPER) {
			paper_complete = handle_end_paper_screen();
		}
		else if (key == DEO_KEYSTROKE_DELETE) {
			delete_deo_preference();
		}
		else {
			update_deo_preference(key);
		}
	}

	return cancelled;

}
/* DDS3.14: Handle END PAPER Screen */
static bool handle_end_paper_screen(void)
{
	struct image *message;
	enum deo_keystroke key;
	struct cursor cursor, default_cursor;
	
	cursor = get_cursor_position();
	default_cursor.group_index = DEFAULT_DEO_CURSOR_X;
	default_cursor.screen_candidate_index = DEFAULT_DEO_CURSOR_Y;
	
	/*clear_screen();*/
	message = get_finish_prompt();
	paste_image(0,0,message);

	while (1) {
		key = interpret_deo_keystroke();
		/* DEO is sure */
		if (key == DEO_KEYSTROKE_DELETE) {
			clear_screen();
			reset_deo_cursor();
			return true;
		}
		/* DEO changes its mind */
		else if (key == DEO_KEYSTROKE_DOWN) {
			/*clear_screen();*/
			dsp_mn_vt_scn();
			draw_group_entry(default_cursor, NO, NO);
			draw_group_entry(cursor, YES, NO);
			return false;
		}
	}
}
예제 #6
0
static void mouse_button_callback(GLFWwindow *window, int button, int action,
                                  int mods)
{
    UNUSED(window);
    UNUSED(button);
    UNUSED(mods);

    if(action == GLFW_PRESS)
    {
        struct Vertex cursor_pos = get_cursor_position();
        set_robot_destination(cursor_pos);
    }
}
예제 #7
0
파일: escseq.c 프로젝트: NgoHuy/uim
/*
 * カーソル位置を保存する
 */
void put_save_cursor(void)
{
  if (!s_save) {
    s_save = TRUE;
    debug(("<put_save_cursor>"));
    if (g_opt.no_report_cursor) {
      my_putp(save_cursor);
      s_save_cursor = s_cursor;
      /* put_exit_attribute_mode(); */
    } else {
      s_save_cursor = get_cursor_position();
    }
  }
}
예제 #8
0
/* DDS3.2.12: Move Cursor */
void move_cursor(enum input_event next)
{
	struct cursor cursor;

	if ((next == INPUT_UP) || (next == INPUT_DOWN) || (next == INPUT_NEXT)
	    || (next == INPUT_PREVIOUS)) {
		
		/* Unhighlight old screen location */
		cursor = get_cursor_position();
		draw_group_entry(cursor, NO, false);
		
		/* Highlight new screen location */
		update_ccp(cursor, next);
	}
}
예제 #9
0
void mouse_initiate_drag(HSClient* client, MouseDragFunction function) {
    g_drag_function = function;
    g_win_drag_client = client;
    g_drag_monitor = find_monitor_with_tag(client->tag);
    if (!g_drag_monitor || client->tag->floating == false) {
        // only can drag wins in  floating mode
        g_win_drag_client = NULL;
        g_drag_function = NULL;
        return;
    }
    client_set_dragged(g_win_drag_client, true);
    g_win_drag_start = g_win_drag_client->float_size;
    g_button_drag_start = get_cursor_position();
    XGrabPointer(g_display, client->window, True,
        PointerMotionMask|ButtonReleaseMask, GrabModeAsync,
            GrabModeAsync, None, None, CurrentTime);
}
예제 #10
0
// Record all mouse coordinates for the specified time.
std::vector<POINT> VirtualMouse::record_mouse_movement(int seconds) const
{
	// Check if the time is valid.
	if (seconds > 0)
	{
		std::vector<POINT> points;
		std::clock_t timer = std::clock();

		while (std::clock() - timer < seconds * 1000)
		{
			points.push_back(get_cursor_position());
		}

		return points;
	}

	else
	{
		throw std::runtime_error("Invalid number of seconds.");
	}
}
예제 #11
0
/* DDS3.2.20: Add Preference */	
void add_preference(void)
{
	struct cursor cursor;
	/* SIPL 2011-06-28 No longer needed because of new translate
	   function.
	const struct ballot_contents *ballot;
	unsigned int num_candidates; */
	unsigned int dbci;
	const struct rotation *rotation;
	bool candidate_found;

	rotation = get_current_rotation();

	cursor = get_cursor_position();
	
	/* If cursor is on a group heading, then ignore selection */
	if (cursor.screen_candidate_index >= 0) {
	/* SIPL 2011-06-28 No longer needed because of new translate
	   function.
		ballot = get_ballot_contents();
	
		num_candidates = ballot->num_candidates[cursor.group_index];
	*/
		
		/* SIPL 2011-06-28 Use updated translate function. */
		dbci = translate_group_sci_to_dbci(cursor.group_index,
				     cursor.screen_candidate_index, 
				     rotation);
		/* Check if this candidate has already been added to the 
		   Vote in Progress */
		candidate_found = search_vip(cursor.group_index, dbci);
		
		if (!candidate_found) {
			add_candidate(cursor.group_index, dbci);
			/* Interrupt audio */
			draw_group_entry(cursor, YES, true);
		}
	}
}
예제 #12
0
파일: escseq.c 프로젝트: NgoHuy/uim
/*
 * 端末をrawモードにする
 */
void fixtty(void)
{
  struct point_tag start_cursor;
  struct point_tag cursor;
  struct point_tag cursor2;
  static struct termios tios;

  tcgetattr(g_win_in, &tios);
  cfmakeraw(&tios);
  /* read_stdinが戻るまでに読まなければならない最小の文字数 */
  tios.c_cc[VMIN] = 0;
  /* read_stdinが戻るまでのタイムアウト 0.1秒単位 */
  tios.c_cc[VTIME] = 3;
  tcsetattr(g_win_in, TCSANOW, &tios);

  if (s_init) {
    s_cursor.row = s_cursor.col = UNDEFINED;
    /* 前回終了時の位置に戻る */
    put_restore_cursor();
  }

  if (!g_opt.no_report_cursor) {
    /* 開始位置を保存 */
    start_cursor = get_cursor_position();
    if (start_cursor.row == UNDEFINED) {
      g_opt.no_report_cursor = TRUE;
    }
  }

  if (g_opt.no_report_cursor) {
    if (g_opt.status_type == LASTLINE) {
      put_cursor_invisible();
      put_crlf();
      my_putp(cursor_up);
      put_save_cursor();
      put_change_scroll_region(0, g_win->ws_row - 1);
      put_restore_cursor();
      put_cursor_normal();
    }
    draw_statusline_force_restore();
    return;
  }

  put_cursor_invisible();
  /* 最下行から開始したときのためにスクロール */
  if (g_opt.status_type == LASTLINE) {
    write(g_win_out, "\n", strlen("\n"));
  }

  if (!s_init) {
    s_cursor.row = s_cursor.col = UNDEFINED;
    /* 安全な位置に移動 */
    put_cursor_address(1, 1);
    s_cursor.row = s_cursor.col = UNDEFINED;
    /* カーソル位置を取得 */
    cursor = get_cursor_position();
    s_cursor.row = s_cursor.col = UNDEFINED;
    /* 取得したカーソル位置に移動 */
    put_cursor_address_p(&cursor);
    s_cursor.row = s_cursor.col = UNDEFINED;
    /* 同じカーソル位置が得られるか */
    cursor2 = get_cursor_position();
    /* 得られなかったら差分を調べる */
    s_cursor_diff.row = cursor2.row - cursor.row;
    s_cursor_diff.col = cursor2.col - cursor.col;
    start_cursor.row -= s_cursor_diff.row;
    start_cursor.col -= s_cursor_diff.col;
  }

  if (g_opt.status_type == LASTLINE) {
    put_change_scroll_region(0, g_win->ws_row - 1);
  }
  draw_statusline_force_no_restore();
  /* 開始位置に戻る */
  put_cursor_address_p(&start_cursor);
  put_cursor_normal();
}
예제 #13
0
//*****************************************************************************
//
// This function reads a line of text from the player.
//
//*****************************************************************************
int
input_line(int buflen, char *buffer, int timeout, int *read_size)
{
    int iRow, iColumn;
    long lChar;

    //
    // Loop forever.  This loop will be explicitly when appropriate.
    //
    while(1)
    {
        //
        // Read a character.
        //
        lChar = input_character(timeout);

        //
        // If the ZIP interpreter has been halted, then return immediately.
        //
        if(halt)
        {
            return('\n');
        }

        //
        // See if a backsapce or delete character was read.
        //
        if((lChar == '\b') || (lChar == 0x7f))
        {
            //
            // See if there are any characters in the buffer.
            //
            if(*read_size != 0)
            {
                //
                // Decrement the number of characters in the buffer.
                //
                (*read_size)--;

                //
                // Get the cursor position.
                //
                get_cursor_position(&iRow, &iColumn);

                //
                // Move the cursor one character to the left.
                //
                move_cursor(iRow, --iColumn);

                //
                // Display a space to erase the previous character.
                //
                display_char(' ');

                //
                // Move the cursor back to the left.
                //
                move_cursor(iRow, iColumn);
            }
        }

        //
        // See if this a carriage return or newline character.
        //
        else if((lChar == '\n') || (lChar == '\r'))
        {
            //
            // Ignore this character if the previous character was the opposite
            // of the CR/LF pair.
            //
            if(((lChar == '\n') && (g_lPrevChar != '\r')) ||
               ((lChar == '\r') && (g_lPrevChar != '\n')))
            {
                //
                // Save this character as the previous character.
                //
                g_lPrevChar = lChar;

                //
                // Scroll the screen.
                //
                scroll_line();

                //
                // Return the most recently read character.
                //
                return(lChar);
            }
        }

        //
        // See if there is space in the buffer for another character.
        //
        else if(*read_size != (buflen - 1))
        {
            //
            // Save this character in the buffer.
            //
            buffer[(*read_size)++] = lChar;

            //
            // Display this character.
            //
            display_char(lChar);
        }

        //
        // Save this character as the previous character.
        //
        g_lPrevChar = lChar;
    }
}