mirror of
https://github.com/rkd77/elinks.git
synced 2024-09-28 03:06:20 -04:00
Compare commits
2 Commits
0f1e056875
...
110cdef5c2
Author | SHA1 | Date | |
---|---|---|---|
|
110cdef5c2 | ||
|
23c5c8b866 |
@ -64,6 +64,7 @@ enum led_option {
|
|||||||
LEDS_CLOCK_ALIAS,
|
LEDS_CLOCK_ALIAS,
|
||||||
|
|
||||||
LEDS_SHOW_IP_ENABLE,
|
LEDS_SHOW_IP_ENABLE,
|
||||||
|
LEDS_SHOW_MEM_ENABLE,
|
||||||
|
|
||||||
LEDS_TEMPERATURE_TREE,
|
LEDS_TEMPERATURE_TREE,
|
||||||
LEDS_TEMPERATURE_ENABLE,
|
LEDS_TEMPERATURE_ENABLE,
|
||||||
@ -96,6 +97,10 @@ static union option_info led_options[] = {
|
|||||||
"show_ip", OPT_ZERO, 0,
|
"show_ip", OPT_ZERO, 0,
|
||||||
N_("Whether to display IP of the document in the status bar.")),
|
N_("Whether to display IP of the document in the status bar.")),
|
||||||
|
|
||||||
|
INIT_OPT_BOOL("ui", N_("Show available memory"),
|
||||||
|
"show_mem", OPT_ZERO, 0,
|
||||||
|
N_("Whether to display available memory. From /proc/meminfo.")),
|
||||||
|
|
||||||
INIT_OPT_TREE("ui", N_("Temperature"),
|
INIT_OPT_TREE("ui", N_("Temperature"),
|
||||||
"temperature", OPT_ZERO, N_("Temperature of CPU.")),
|
"temperature", OPT_ZERO, N_("Temperature of CPU.")),
|
||||||
|
|
||||||
@ -125,6 +130,7 @@ static union option_info led_options[] = {
|
|||||||
#define get_leds_clock_format() get_opt_leds(LEDS_CLOCK_FORMAT).string
|
#define get_leds_clock_format() get_opt_leds(LEDS_CLOCK_FORMAT).string
|
||||||
#define get_leds_panel_enable() get_opt_leds(LEDS_PANEL_ENABLE).number
|
#define get_leds_panel_enable() get_opt_leds(LEDS_PANEL_ENABLE).number
|
||||||
#define get_leds_show_ip_enable() get_opt_leds(LEDS_SHOW_IP_ENABLE).number
|
#define get_leds_show_ip_enable() get_opt_leds(LEDS_SHOW_IP_ENABLE).number
|
||||||
|
#define get_leds_show_mem_enable() get_opt_leds(LEDS_SHOW_MEM_ENABLE).number
|
||||||
#define get_leds_temperature_enable() get_opt_leds(LEDS_TEMPERATURE_ENABLE).number
|
#define get_leds_temperature_enable() get_opt_leds(LEDS_TEMPERATURE_ENABLE).number
|
||||||
#define get_leds_temperature_filename() get_opt_leds(LEDS_TEMPERATURE_FILENAME).string
|
#define get_leds_temperature_filename() get_opt_leds(LEDS_TEMPERATURE_FILENAME).string
|
||||||
|
|
||||||
@ -209,6 +215,58 @@ draw_show_ip(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
draw_show_mem(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
||||||
|
{
|
||||||
|
struct terminal *term = ses->tab->term;
|
||||||
|
FILE *f;
|
||||||
|
struct string text;
|
||||||
|
int i;
|
||||||
|
int length;
|
||||||
|
char *pos;
|
||||||
|
size_t ret = 0;
|
||||||
|
|
||||||
|
f = fopen("/proc/meminfo", "r");
|
||||||
|
|
||||||
|
if (!f) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!feof(f)) {
|
||||||
|
char buffer[128];
|
||||||
|
|
||||||
|
if (!fgets(buffer, 127, f)) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (strncmp(buffer, "MemAvailable:", sizeof("MemAvailable:")-1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (sscanf(buffer, "MemAvailable:%ld", &ret) < 1) {
|
||||||
|
ret = 0;
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
if (ret < 1) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!init_string(&text)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
add_format_to_string(&text, "[%ld MiB]", ret / 1024);
|
||||||
|
length = text.length;
|
||||||
|
for (i = 0, pos = text.source; i < length; i++) {
|
||||||
|
draw_char(term, xpos - length + i, ypos, pos[i], 0, color);
|
||||||
|
}
|
||||||
|
done_string(&text);
|
||||||
|
|
||||||
|
return length;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
draw_temperature(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
draw_temperature(struct session *ses, int xpos, int ypos, struct color_pair *color)
|
||||||
{
|
{
|
||||||
@ -332,6 +390,12 @@ draw_leds(struct session *ses)
|
|||||||
if (color) term->leds_length += draw_temperature(ses, xpos - term->leds_length, ypos, color);
|
if (color) term->leds_length += draw_temperature(ses, xpos - term->leds_length, ypos, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (get_leds_show_mem_enable()) {
|
||||||
|
struct color_pair *color = get_bfu_color(term, "status.showmem-text");
|
||||||
|
|
||||||
|
if (color) term->leds_length += draw_show_mem(ses, xpos - term->leds_length, ypos, color);
|
||||||
|
}
|
||||||
|
|
||||||
if (get_leds_show_ip_enable()) {
|
if (get_leds_show_ip_enable()) {
|
||||||
struct color_pair *color = get_bfu_color(term, "status.showip-text");
|
struct color_pair *color = get_bfu_color(term, "status.showip-text");
|
||||||
|
|
||||||
|
@ -1356,6 +1356,10 @@ static union option_info config_options_info[] = {
|
|||||||
"showip-text", "black", "white", "black", "white",
|
"showip-text", "black", "white", "black", "white",
|
||||||
N_("Status bar show ip text colors.")),
|
N_("Status bar show ip text colors.")),
|
||||||
|
|
||||||
|
INIT_OPT_COLORS(".status", N_("Status bar show available memory"),
|
||||||
|
"showmem-text", "black", "white", "black", "white",
|
||||||
|
N_("Status bar show available memory text colors.")),
|
||||||
|
|
||||||
INIT_OPT_COLORS(".status", N_("Generic status bar"),
|
INIT_OPT_COLORS(".status", N_("Generic status bar"),
|
||||||
"status-bar", "black", "white", "black", "white",
|
"status-bar", "black", "white", "black", "white",
|
||||||
N_("Generic status bar colors.")),
|
N_("Generic status bar colors.")),
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
|
|
||||||
#include "cache/cache.h"
|
#include "cache/cache.h"
|
||||||
#include "config/conf.h"
|
#include "config/conf.h"
|
||||||
|
#include "config/options.h"
|
||||||
#include "network/connection.h"
|
#include "network/connection.h"
|
||||||
#include "protocol/about.h"
|
#include "protocol/about.h"
|
||||||
#include "protocol/protocol.h"
|
#include "protocol/protocol.h"
|
||||||
@ -97,7 +98,7 @@ about_protocol_handler(struct connection *conn)
|
|||||||
if (cached && !cached->content_type) {
|
if (cached && !cached->content_type) {
|
||||||
#ifndef CONFIG_SMALL
|
#ifndef CONFIG_SMALL
|
||||||
{
|
{
|
||||||
if (!strncmp(conn->uri->data, "config", 6)) {
|
if (!strncmp(conn->uri->data, "config", 6) && !get_cmd_opt_bool("anonymous")) {
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
if (conn->referrer && conn->referrer->protocol == PROTOCOL_ABOUT) {
|
if (conn->referrer && conn->referrer->protocol == PROTOCOL_ABOUT) {
|
||||||
|
Loading…
Reference in New Issue
Block a user