Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
I3csstatus
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jiří Kalvoda
I3csstatus
Commits
0484ecd7
Commit
0484ecd7
authored
2 years ago
by
Jiří Kalvoda
Browse files
Options
Downloads
Patches
Plain Diff
Create ModuleParent interface.
parent
13542afd
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Module.cs
+13
-13
13 additions, 13 deletions
Module.cs
Parsers.cs
+9
-9
9 additions, 9 deletions
Parsers.cs
Program.cs
+9
-3
9 additions, 3 deletions
Program.cs
with
31 additions
and
25 deletions
Module.cs
+
13
−
13
View file @
0484ecd7
...
...
@@ -102,7 +102,7 @@ class GlobalModuleResource
interface
Module
{
IEnumerable
<
Element
>
Get
();
void
Init
(
StatusBar
_bar
,
ConfigSection
section
);
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
);
}
...
...
@@ -111,7 +111,7 @@ class ModuleConstant: Module
{
string
text
;
Color
color
;
public
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
text
=
section
.
Mandatory
(
"text"
);
color
=
section
?[
"color"
]?.
AsColor
()
??
System
.
Drawing
.
ColorTranslator
.
FromHtml
(
"white"
);
...
...
@@ -130,7 +130,7 @@ class ModuleFile: Module
InnerStatusBar
ifNotFound
;
InnerStatusBar
ifReadError
;
Parser
parser
;
public
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
path
=
section
.
Mandatory
(
"path"
).
AsPath
();
ifNotFound
=
new
InnerStatusBar
(
_bar
,
section
.
Optional
(
"not_found_handler"
)?.
AsConfig
()
??
...
...
@@ -173,7 +173,7 @@ text = ERR
abstract
class
ModuleSourceThreadAndParser
:
Module
{
protected
StatusBar
bar
;
protected
ModuleParent
bar
;
protected
string
data
;
protected
long
dataTick
;
Thread
inputThread
;
...
...
@@ -183,7 +183,7 @@ abstract class ModuleSourceThreadAndParser: Module
int
?
maxOld_ms
;
int
?
showOld_ms
;
protected
abstract
void
inputThreadFunc
();
public
virtual
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
virtual
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
bar
=
_bar
;
ifNoData
=
new
InnerStatusBar
(
_bar
,
section
.
Optional
(
"no_data_handler"
)?.
AsConfig
()
??
...
...
@@ -235,7 +235,7 @@ abstract class ModuleSourceThreadAndParser: Module
abstract
class
ModuleAbstractPipe
:
ModuleSourceThreadAndParser
{
int
msgSeparator
;
public
override
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
override
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
msgSeparator
=
section
.
Optional
(
"separator"
)?.
AsInt
()
??
0
;
base
.
Init
(
_bar
,
section
);
...
...
@@ -279,7 +279,7 @@ abstract class ModuleAbstractPipe: ModuleSourceThreadAndParser
class
ModulePipe
:
ModuleAbstractPipe
{
string
path
;
public
override
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
override
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
path
=
section
.
Mandatory
(
"path"
).
AsPath
();
base
.
Init
(
_bar
,
section
);
...
...
@@ -314,7 +314,7 @@ class ModuleExec: ModuleAbstractPipe
string
arguments
;
Process
process
;
string
stdinString
;
public
override
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
override
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
programName
=
section
.
Mandatory
(
"program"
).
AsPath
();
stdinString
=
section
.
Optional
(
"stdin"
)?.
AsString
()
??
""
;
...
...
@@ -346,7 +346,7 @@ class ModuleHttp: ModuleSourceThreadAndParser
InnerStatusBar
ifReadError
;
int
period_ms
;
int
timeout_ms
;
public
override
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
override
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
url
=
section
.
Mandatory
(
"url"
).
AsString
();
ifReadError
=
new
InnerStatusBar
(
_bar
,
section
.
Optional
(
"error_handler"
)?.
AsConfig
()
??
...
...
@@ -493,7 +493,7 @@ class ModuleI3Status: Module
}
}
}
public
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
name
=
section
[
"name"
];
configuration
=
section
.
Optional
(
"config"
)?.
AsString
();
...
...
@@ -517,12 +517,12 @@ class ModuleI3Status: Module
[
ModuleName
(
"time"
)]
class
ModuleTime
:
Module
{
StatusBar
bar
;
ModuleParent
bar
;
string
format
;
string
shortFormat
;
bool
refresh
;
int
round_ms
;
public
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
bar
=
_bar
;
format
=
section
.
Optional
(
"format"
)?.
AsString
()
??
"yyyy-MM-dd HH:mm:ss"
;
...
...
@@ -559,7 +559,7 @@ class ModuleBattery: Module
int
energy
);
Queue
<
HistoryElement
>
history
=
new
();
public
void
Init
(
StatusBar
_bar
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
ConfigSection
section
)
{
string
instance
=
section
.
Optional
(
"instance"
)?.
AsString
()
??
"BAT1"
;
path
=
section
.
Optional
(
"path"
)?.
AsPath
()
??
$"/sys/class/power_supply/
{
instance
}
/uevent"
;
...
...
This diff is collapsed.
Click to expand it.
Parsers.cs
+
9
−
9
View file @
0484ecd7
...
...
@@ -96,7 +96,7 @@ class ParserGetter: GlobalModuleResource
interface
Parser
{
IEnumerable
<
Element
>
Parse
(
string
s
);
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
);
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
);
}
#nullable disable
...
...
@@ -105,7 +105,7 @@ interface Parser
class
ParserText
:
Parser
{
Color
color
;
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
color
=
section
.
Optional
(
"color"
)?.
AsColor
()
??
System
.
Drawing
.
ColorTranslator
.
FromHtml
(
"white"
);
}
...
...
@@ -119,7 +119,7 @@ class ParserText: Parser
[
ParserName
(
"osdd_last"
)]
class
ParserOsddLast
:
Parser
{
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Element
>
Parse
(
string
data
)
...
...
@@ -148,8 +148,8 @@ class ParserOsddLast: Parser
[
ParserName
(
"checkmail_status"
)]
class
ParserCheckmailLog
:
Parser
{
StatusBar
bar
;
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
ModuleParent
bar
;
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
bar
=
_bar
;
}
...
...
@@ -192,7 +192,7 @@ class ParserCheckmailLog: Parser
[
ParserName
(
"offlineimap_status"
)]
class
ParserOfflineimapLog
:
Parser
{
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Element
>
Parse
(
string
data
)
...
...
@@ -217,7 +217,7 @@ class ParserOfflineimapLog: Parser
[
ParserName
(
"i3"
)]
class
ParserI3
:
Parser
{
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
){}
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
){}
static
Element
parseElement
(
JsonNode
_json
)
{
var
json
=
_json
.
AsObject
();
...
...
@@ -268,7 +268,7 @@ class ParserI3: Parser
class
ParserICESpeed
:
Parser
{
#
pragma
warning
disable
8602
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Element
>
Parse
(
string
data
)
...
...
@@ -291,7 +291,7 @@ class ParserICESpeed: Parser
class
ParserICENextStop
:
Parser
{
#
pragma
warning
disable
8602
public
void
Init
(
StatusBar
_bar
,
Module
_module
,
ConfigSection
section
)
public
void
Init
(
ModuleParent
_bar
,
Module
_module
,
ConfigSection
section
)
{
}
public
IEnumerable
<
Element
>
Parse
(
string
data
)
...
...
This diff is collapsed.
Click to expand it.
Program.cs
+
9
−
3
View file @
0484ecd7
...
...
@@ -118,7 +118,13 @@ record Element(
);
abstract
class
StatusBar
interface
ModuleParent
{
public
abstract
void
Schedule
(
int
in_ms
);
public
abstract
T
GetGlobal
<
T
>()
where
T
:
GlobalModuleResource
,
new
();
}
abstract
class
StatusBar
:
ModuleParent
{
List
<
Module
>
modules
=
new
();
protected
void
parseConfigFile
(
FileInfo
configFile
)
...
...
@@ -171,8 +177,8 @@ abstract class StatusBar
class
InnerStatusBar
:
StatusBar
{
StatusBar
parrent
;
public
InnerStatusBar
(
StatusBar
_parrent
,
ConfigParser
p
)
ModuleParent
parrent
;
public
InnerStatusBar
(
ModuleParent
_parrent
,
ConfigParser
p
)
{
parrent
=
_parrent
;
parseConfig
(
p
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment