mirror of
https://github.com/rkd77/elinks.git
synced 2025-04-18 00:47:36 -04:00
[terminal] exec_on_terminal and related rewritten a bit to allow const param
This commit is contained in:
parent
e0e88dc5a7
commit
277f341d2b
@ -463,7 +463,7 @@ set_clipboard_text(char *data)
|
|||||||
|
|
||||||
/* Set xterm-like term window's title. */
|
/* Set xterm-like term window's title. */
|
||||||
void
|
void
|
||||||
set_window_title(char *title, int codepage)
|
set_window_title(const char *ctitle, int codepage)
|
||||||
{
|
{
|
||||||
struct string filtered;
|
struct string filtered;
|
||||||
|
|
||||||
@ -472,10 +472,19 @@ set_window_title(char *title, int codepage)
|
|||||||
if (!is_xterm()) return;
|
if (!is_xterm()) return;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!init_string(&filtered)) return;
|
if (!init_string(&filtered)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Copy title to filtered if different from NULL */
|
/* Copy title to filtered if different from NULL */
|
||||||
if (title) {
|
if (ctitle) {
|
||||||
|
char *title = stracpy(ctitle);
|
||||||
|
|
||||||
|
if (!title) {
|
||||||
|
done_string(&filtered);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
char *scan = title;
|
char *scan = title;
|
||||||
char *end = title + strlen(title);
|
char *end = title + strlen(title);
|
||||||
|
|
||||||
@ -488,7 +497,7 @@ set_window_title(char *title, int codepage)
|
|||||||
* potential alternative set_window_title() routines might
|
* potential alternative set_window_title() routines might
|
||||||
* want to take different precautions. */
|
* want to take different precautions. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
char *charbegin = scan;
|
const char *charbegin = scan;
|
||||||
unicode_val_T unicode
|
unicode_val_T unicode
|
||||||
= cp_to_unicode(codepage, &scan, end);
|
= cp_to_unicode(codepage, &scan, end);
|
||||||
int charlen = scan - charbegin;
|
int charlen = scan - charbegin;
|
||||||
@ -519,6 +528,7 @@ set_window_title(char *title, int codepage)
|
|||||||
|
|
||||||
add_bytes_to_string(&filtered, charbegin, charlen);
|
add_bytes_to_string(&filtered, charbegin, charlen);
|
||||||
}
|
}
|
||||||
|
mem_free(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send terminal escape sequence + title string */
|
/* Send terminal escape sequence + title string */
|
||||||
|
@ -42,7 +42,7 @@ void resume_mouse(void *);
|
|||||||
int start_thread(void (*)(void *, int), void *, int);
|
int start_thread(void (*)(void *, int), void *, int);
|
||||||
char *get_clipboard_text(void);
|
char *get_clipboard_text(void);
|
||||||
void set_clipboard_text(char *);
|
void set_clipboard_text(char *);
|
||||||
void set_window_title(char *, int codepage);
|
void set_window_title(const char *, int codepage);
|
||||||
char *get_window_title(int codepage);
|
char *get_window_title(int codepage);
|
||||||
void block_stdin(void);
|
void block_stdin(void);
|
||||||
void unblock_stdin(void);
|
void unblock_stdin(void);
|
||||||
|
@ -483,15 +483,22 @@ free_itrm(struct itrm *itrm)
|
|||||||
* @a text should look like "width,height,old-width,old-height"
|
* @a text should look like "width,height,old-width,old-height"
|
||||||
* where width and height are integers. */
|
* where width and height are integers. */
|
||||||
static inline void
|
static inline void
|
||||||
resize_terminal_from_str(char *text)
|
resize_terminal_from_str(const char *text_)
|
||||||
{
|
{
|
||||||
enum { NEW_WIDTH = 0, NEW_HEIGHT, OLD_WIDTH, OLD_HEIGHT, NUMBERS };
|
enum { NEW_WIDTH = 0, NEW_HEIGHT, OLD_WIDTH, OLD_HEIGHT, NUMBERS };
|
||||||
int numbers[NUMBERS];
|
int numbers[NUMBERS];
|
||||||
int i;
|
int i;
|
||||||
|
char *text2, *text;
|
||||||
|
|
||||||
assert(text && *text);
|
assert(text_ && *text_);
|
||||||
if_assert_failed return;
|
if_assert_failed return;
|
||||||
|
|
||||||
|
text2 = stracpy(text_);
|
||||||
|
if (!text2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
text = text2;
|
||||||
|
|
||||||
for (i = 0; i < NUMBERS; i++) {
|
for (i = 0; i < NUMBERS; i++) {
|
||||||
char *p = strchr(text, ',');
|
char *p = strchr(text, ',');
|
||||||
|
|
||||||
@ -499,6 +506,7 @@ resize_terminal_from_str(char *text)
|
|||||||
*p++ = '\0';
|
*p++ = '\0';
|
||||||
|
|
||||||
} else if (i < OLD_HEIGHT) {
|
} else if (i < OLD_HEIGHT) {
|
||||||
|
mem_free(text2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,10 +518,11 @@ resize_terminal_from_str(char *text)
|
|||||||
resize_window(numbers[NEW_WIDTH], numbers[NEW_HEIGHT],
|
resize_window(numbers[NEW_WIDTH], numbers[NEW_HEIGHT],
|
||||||
numbers[OLD_WIDTH], numbers[OLD_HEIGHT]);
|
numbers[OLD_WIDTH], numbers[OLD_HEIGHT]);
|
||||||
resize_terminal();
|
resize_terminal();
|
||||||
|
mem_free(text2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
dispatch_special(char *text)
|
dispatch_special(const char *text)
|
||||||
{
|
{
|
||||||
switch (text[0]) {
|
switch (text[0]) {
|
||||||
case TERM_FN_TITLE:
|
case TERM_FN_TITLE:
|
||||||
|
@ -139,7 +139,7 @@ void block_itrm(void);
|
|||||||
int unblock_itrm(void);
|
int unblock_itrm(void);
|
||||||
void free_all_itrms(void);
|
void free_all_itrms(void);
|
||||||
void resize_terminal(void);
|
void resize_terminal(void);
|
||||||
void dispatch_special(char *);
|
void dispatch_special(const char *);
|
||||||
void kbd_ctrl_c(void);
|
void kbd_ctrl_c(void);
|
||||||
int is_blocked(void);
|
int is_blocked(void);
|
||||||
void get_terminal_name(char[MAX_TERM_LEN]);
|
void get_terminal_name(char[MAX_TERM_LEN]);
|
||||||
|
@ -278,7 +278,7 @@ assert_terminal_ptr_not_dangling(const struct terminal *suspect)
|
|||||||
static void
|
static void
|
||||||
exec_on_master_terminal(struct terminal *term,
|
exec_on_master_terminal(struct terminal *term,
|
||||||
char *path, int plen,
|
char *path, int plen,
|
||||||
char *delete_, int dlen,
|
const char *delete_, int dlen,
|
||||||
term_exec_T fg)
|
term_exec_T fg)
|
||||||
{
|
{
|
||||||
int blockh;
|
int blockh;
|
||||||
@ -320,8 +320,8 @@ exec_on_master_terminal(struct terminal *term,
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
exec_on_slave_terminal( struct terminal *term,
|
exec_on_slave_terminal( struct terminal *term,
|
||||||
char *path, int plen,
|
char *path, int plen,
|
||||||
char *delete_, int dlen,
|
const char *delete_, int dlen,
|
||||||
term_exec_T fg)
|
term_exec_T fg)
|
||||||
{
|
{
|
||||||
int data_size = plen + dlen + 1 /* 0 */ + 1 /* fg */ + 2 /* 2 null char */;
|
int data_size = plen + dlen + 1 /* 0 */ + 1 /* fg */ + 2 /* 2 null char */;
|
||||||
@ -339,7 +339,7 @@ exec_on_slave_terminal( struct terminal *term,
|
|||||||
|
|
||||||
void
|
void
|
||||||
exec_on_terminal(struct terminal *term, char *path,
|
exec_on_terminal(struct terminal *term, char *path,
|
||||||
char *delete_, term_exec_T fg)
|
const char *delete_, term_exec_T fg)
|
||||||
{
|
{
|
||||||
if (path) {
|
if (path) {
|
||||||
if (!*path) return;
|
if (!*path) return;
|
||||||
|
@ -232,7 +232,7 @@ enum term_exec {
|
|||||||
|
|
||||||
typedef int term_exec_T;
|
typedef int term_exec_T;
|
||||||
|
|
||||||
void exec_on_terminal(struct terminal *, char *, char *, term_exec_T);
|
void exec_on_terminal(struct terminal *, char *, const char *, term_exec_T);
|
||||||
void exec_shell(struct terminal *term);
|
void exec_shell(struct terminal *term);
|
||||||
|
|
||||||
int set_terminal_title(struct terminal *, char *);
|
int set_terminal_title(struct terminal *, char *);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user