mirror of
https://github.com/davatorium/rofi.git
synced 2024-12-02 14:05:13 -05:00
[DMenu] Add -ellipsize-mode option.
This commit is contained in:
parent
66d782e0e7
commit
063195922f
8 changed files with 47 additions and 10 deletions
|
@ -298,6 +298,15 @@ When multi-select is enabled, prefix this string when element is not selected.
|
|||
.PP
|
||||
\fIdefault\fP: "☐ "
|
||||
|
||||
.PP
|
||||
\fB\fC-ellipsize-mode\fR (start|middle|end)
|
||||
|
||||
.PP
|
||||
Set ellipsize mode on the listview.
|
||||
|
||||
.PP
|
||||
\fIdefault\fP "end"
|
||||
|
||||
.SH PARSING ROW OPTIONS
|
||||
.PP
|
||||
Extra options for individual rows can be also set. See the \fBrofi-script(5)\fP manpage for details; the syntax and supported features are identical.
|
||||
|
|
|
@ -192,6 +192,12 @@ When multi-select is enabled, prefix this string when element is not selected.
|
|||
|
||||
*default*: "☐ "
|
||||
|
||||
`-ellipsize-mode` (start|middle|end)
|
||||
|
||||
Set ellipsize mode on the listview.
|
||||
|
||||
*default* "end"
|
||||
|
||||
## PARSING ROW OPTIONS
|
||||
|
||||
Extra options for individual rows can be also set. See the **rofi-script(5)** manpage for details; the syntax and supported features are identical.
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define ROFI_VIEW_H
|
||||
|
||||
#include "mode.h"
|
||||
#include <pango/pango.h>
|
||||
#include <xcb/xcb.h>
|
||||
/**
|
||||
* @defgroup View View
|
||||
|
@ -338,9 +339,12 @@ void rofi_capture_screenshot(void);
|
|||
void rofi_view_set_window_title(const char *title);
|
||||
|
||||
/**
|
||||
@param state The window state handle
|
||||
@param mode The pango ellipsize mode to user
|
||||
* set ellipsize mode to start.
|
||||
*/
|
||||
void rofi_view_ellipsize_start(RofiViewState *state);
|
||||
void rofi_view_ellipsize_listview(RofiViewState *state,
|
||||
PangoEllipsizeMode mode);
|
||||
|
||||
/**
|
||||
* @param new_x New XIM window x pos
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#define ROFI_LISTVIEW_H
|
||||
|
||||
#include "widgets/textbox.h"
|
||||
#include <pango/pango.h>
|
||||
|
||||
/**
|
||||
* @defgroup listview listview
|
||||
|
@ -276,7 +277,7 @@ void listview_toggle_ellipsizing(listview *lv);
|
|||
* Set ellipsize mode to start.
|
||||
*/
|
||||
|
||||
void listview_set_ellipsize_start(listview *lv);
|
||||
void listview_set_ellipsize(listview *lv, PangoEllipsizeMode mode);
|
||||
|
||||
/**
|
||||
* @param lv Handler to the listview object.
|
||||
|
|
|
@ -7,6 +7,6 @@ pluginsdir=@libdir@/rofi/
|
|||
|
||||
Name: rofi
|
||||
Description: Header files for rofi plugins
|
||||
Requires.private: glib-2.0 >= 2.40 gmodule-2.0 cairo
|
||||
Requires.private: glib-2.0 >= 2.40 gmodule-2.0 cairo pango
|
||||
Version: @VERSION@
|
||||
Cflags: -I${includedir}/
|
||||
|
|
|
@ -29,8 +29,8 @@
|
|||
#define G_LOG_DOMAIN "Modes.DMenu"
|
||||
#include "config.h"
|
||||
|
||||
#include "modes/dmenu.h"
|
||||
#include "helper.h"
|
||||
#include "modes/dmenu.h"
|
||||
#include "rofi-icon-fetcher.h"
|
||||
#include "rofi.h"
|
||||
#include "settings.h"
|
||||
|
@ -299,7 +299,7 @@ static gpointer read_input_thread(gpointer userdata) {
|
|||
i = 0;
|
||||
if (block) {
|
||||
double elapsed = g_timer_elapsed(tim, NULL);
|
||||
if ( elapsed >= 0.1 || block->length == BLOCK_LINES_SIZE) {
|
||||
if (elapsed >= 0.1 || block->length == BLOCK_LINES_SIZE) {
|
||||
g_timer_start(tim);
|
||||
g_async_queue_push(pd->async_queue, block);
|
||||
block = NULL;
|
||||
|
@ -957,7 +957,21 @@ int dmenu_mode_dialog(void) {
|
|||
rofi_view_create(&dmenu_mode, input, menu_flags, dmenu_finalize);
|
||||
|
||||
if (find_arg("-keep-right") >= 0) {
|
||||
rofi_view_ellipsize_start(state);
|
||||
rofi_view_ellipsize_listview(state, PANGO_ELLIPSIZE_START);
|
||||
}
|
||||
char *ellipsize_mode = NULL;
|
||||
if (find_arg_str("-ellipsize-mode", &ellipsize_mode) >= 0) {
|
||||
if (ellipsize_mode) {
|
||||
if (g_ascii_strcasecmp(ellipsize_mode, "start") == 0) {
|
||||
rofi_view_ellipsize_listview(state, PANGO_ELLIPSIZE_START);
|
||||
} else if (g_ascii_strcasecmp(ellipsize_mode, "middle") == 0) {
|
||||
rofi_view_ellipsize_listview(state, PANGO_ELLIPSIZE_MIDDLE);
|
||||
} else if (g_ascii_strcasecmp(ellipsize_mode, "end") == 0) {
|
||||
rofi_view_ellipsize_listview(state, PANGO_ELLIPSIZE_END);
|
||||
} else {
|
||||
g_warning("Unrecognized ellipsize mode: '%s'", ellipsize_mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
rofi_view_set_selected_line(state, pd->selected_line);
|
||||
rofi_view_set_active(state);
|
||||
|
@ -1021,4 +1035,6 @@ void print_dmenu_options(void) {
|
|||
"When multi-select is enabled prefix this string when element "
|
||||
"is not selected.",
|
||||
NULL, is_term);
|
||||
print_help_msg("-ellipsize-mode", "end",
|
||||
"Set ellipsize mode(start | middle | end).", NULL, is_term);
|
||||
}
|
||||
|
|
|
@ -2499,8 +2499,9 @@ void rofi_view_clear_input(RofiViewState *state) {
|
|||
}
|
||||
}
|
||||
|
||||
void rofi_view_ellipsize_start(RofiViewState *state) {
|
||||
listview_set_ellipsize_start(state->list_view);
|
||||
void rofi_view_ellipsize_listview(RofiViewState *state,
|
||||
PangoEllipsizeMode mode) {
|
||||
listview_set_ellipsize(state->list_view, mode);
|
||||
}
|
||||
|
||||
void rofi_view_switch_mode(RofiViewState *state, Mode *mode) {
|
||||
|
|
|
@ -1104,9 +1104,9 @@ void listview_set_fixed_num_lines(listview *lv) {
|
|||
}
|
||||
}
|
||||
|
||||
void listview_set_ellipsize_start(listview *lv) {
|
||||
void listview_set_ellipsize(listview *lv, PangoEllipsizeMode mode) {
|
||||
if (lv) {
|
||||
lv->emode = PANGO_ELLIPSIZE_START;
|
||||
lv->emode = mode;
|
||||
for (unsigned int i = 0; i < lv->cur_elements; i++) {
|
||||
textbox_set_ellipsize(lv->boxes[i].textbox, lv->emode);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue