Skip to content

Commit 2618d33

Browse files
committed
Merge branch 'main' of github.com:htop-dev/htop
2 parents b9af536 + ae424de commit 2618d33

16 files changed

Lines changed: 32 additions & 83 deletions

File tree

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
What's new in version 3.5.1
22

3+
* Consolidate ClockMeter code into DateTimeMeter code
34
* Darwin: Fix unsigned underflow in memory meter on ARM64 (Apple Silicon 16K pages showing ~64TB used)
45
* Linux/PCP: Replace M_SHARE (SHR) with M_PRIV (PRIV) in default Main screen columns
56
* PCP: Fix dynamic screen column (instance) sorting (incorrect cast and field offsets)

ClockMeter.c

Lines changed: 0 additions & 46 deletions
This file was deleted.

ClockMeter.h

Lines changed: 0 additions & 15 deletions
This file was deleted.

DateTimeMeter.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ in the source distribution for its full text.
1717
#include "Object.h"
1818

1919

20+
static const int ClockMeter_attributes[] = {
21+
CLOCK
22+
};
23+
2024
static const int DateMeter_attributes[] = {
2125
DATE
2226
};
@@ -25,28 +29,42 @@ static const int DateTimeMeter_attributes[] = {
2529
DATETIME
2630
};
2731

28-
static void DateMeter_updateValues(Meter* this) {
29-
const Machine* host = this->host;
30-
31-
struct tm result;
32-
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
33-
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
34-
}
35-
3632
static void DateTimeMeter_updateValues(Meter* this) {
3733
const Machine* host = this->host;
3834

3935
struct tm result;
4036
const struct tm* lt = localtime_r(&host->realtime.tv_sec, &result);
41-
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
37+
if (As_Meter(this) == &ClockMeter_class) {
38+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%H:%M:%S", lt);
39+
} else if (As_Meter(this) == &DateMeter_class) {
40+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F", lt);
41+
} else {
42+
strftime(this->txtBuffer, sizeof(this->txtBuffer), "%F %H:%M:%S", lt);
43+
}
4244
}
4345

46+
const MeterClass ClockMeter_class = {
47+
.super = {
48+
.extends = Class(Meter),
49+
.delete = Meter_delete
50+
},
51+
.updateValues = DateTimeMeter_updateValues,
52+
.defaultMode = TEXT_METERMODE,
53+
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
54+
.maxItems = 0,
55+
.total = 0.0,
56+
.attributes = ClockMeter_attributes,
57+
.name = "Clock",
58+
.uiName = "Clock",
59+
.caption = "Time: ",
60+
};
61+
4462
const MeterClass DateMeter_class = {
4563
.super = {
4664
.extends = Class(Meter),
4765
.delete = Meter_delete
4866
},
49-
.updateValues = DateMeter_updateValues,
67+
.updateValues = DateTimeMeter_updateValues,
5068
.defaultMode = TEXT_METERMODE,
5169
.supportedModes = (1 << TEXT_METERMODE) | (1 << LED_METERMODE),
5270
.maxItems = 0,

DateTimeMeter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ in the source distribution for its full text.
1010
#include "Meter.h"
1111

1212

13+
extern const MeterClass ClockMeter_class;
14+
1315
extern const MeterClass DateMeter_class;
1416

1517
extern const MeterClass DateTimeMeter_class;

Makefile.am

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ myhtopsources = \
3535
AvailableMetersPanel.c \
3636
BatteryMeter.c \
3737
CategoriesPanel.c \
38-
ClockMeter.c \
3938
ColorsPanel.c \
4039
ColumnsPanel.c \
4140
CommandLine.c \
@@ -103,7 +102,6 @@ myhtopheaders = \
103102
CPUMeter.h \
104103
CRT.h \
105104
CategoriesPanel.h \
106-
ClockMeter.h \
107105
ColorsPanel.h \
108106
ColumnsPanel.h \
109107
CommandLine.h \

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
m4_define([htop_git_version],
99
m4_normalize(m4_esyscmd([git describe --abbrev=7 --dirty --always --tags 2> /dev/null || echo ''])))
10-
m4_define([htop_release_version], [3.5.1-dev])
10+
m4_define([htop_release_version], [3.6.0-dev])
1111

1212
# ----------------------------------------------------------------------
1313
# Autoconf initialization.

darwin/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ in the source distribution for its full text.
3434
#include <IOKit/ps/IOPSKeys.h>
3535
#include <IOKit/storage/IOBlockStorageDriver.h>
3636

37-
#include "ClockMeter.h"
3837
#include "CPUMeter.h"
3938
#include "CRT.h"
4039
#include "DateTimeMeter.h"

dragonflybsd/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ in the source distribution for its full text.
2222
#include <sys/types.h>
2323
#include <vm/vm_param.h>
2424

25-
#include "ClockMeter.h"
2625
#include "CPUMeter.h"
2726
#include "DateTimeMeter.h"
2827
#include "FileDescriptorMeter.h"

freebsd/Platform.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ in the source distribution for its full text.
2727
#include <vm/vm_param.h>
2828

2929
#include "CPUMeter.h"
30-
#include "ClockMeter.h"
3130
#include "DateTimeMeter.h"
3231
#include "DiskIOMeter.h"
3332
#include "FileDescriptorMeter.h"

0 commit comments

Comments
 (0)