Commit 4fd4dd8340

4fd4dd8340aea77e34d74acb9e15519d24676785

parent: 7d85b9d61b

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2020-11-21 15:24 UTC

weechat-matrix: Update for the new prefix enum.

Layout: unified · split

Cargo.lock +1 −3
@@ -1269,6 +1269,7 @@ version = "0.1.0"
1269dependencies = [ 1269dependencies = [
1270 "async-trait", 1270 "async-trait",
1271 "dashmap", 1271 "dashmap",
1272 "futures",
1272 "futures-timer", 1273 "futures-timer",
1273 "http", 1274 "http",
1274 "matrix-sdk-base", 1275 "matrix-sdk-base",
@@ -2883,7 +2884,6 @@ dependencies = [
2883[[package]] 2884[[package]]
2884name = "weechat" 2885name = "weechat"
2885version = "0.4.0" 2886version = "0.4.0"
2886source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
2887dependencies = [ 2887dependencies = [
2888 "async-task", 2888 "async-task",
2889 "async-trait", 2889 "async-trait",
@@ -2899,7 +2899,6 @@ dependencies = [
2899[[package]] 2899[[package]]
2900name = "weechat-macro" 2900name = "weechat-macro"
2901version = "0.4.0" 2901version = "0.4.0"
2902source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
2903dependencies = [ 2902dependencies = [
2904 "libc", 2903 "libc",
2905 "proc-macro2", 2904 "proc-macro2",
@@ -2932,7 +2931,6 @@ dependencies = [
2932[[package]] 2931[[package]]
2933name = "weechat-sys" 2932name = "weechat-sys"
2934version = "0.4.0" 2933version = "0.4.0"
2935source = "git+https://github.com/poljar/rust-weechat#a418b770a4bfa70457792f9817bc966f61cb9be1"
2936dependencies = [ 2934dependencies = [
2937 "bindgen", 2935 "bindgen",
2938 "libc", 2936 "libc",
Cargo.toml +1 −1
@@ -26,7 +26,7 @@ chrono = "0.4.19"
26serde_json = "1.0.59" 26serde_json = "1.0.59"
27 27
28[dependencies.weechat] 28[dependencies.weechat]
29git = "https://github.com/poljar/rust-weechat" 29path = "/home/poljar/werk/misc/rust-weechat/weechat"
30features = ["async", "config_macro"] 30features = ["async", "config_macro"]
31 31
32[dependencies.matrix-sdk] 32[dependencies.matrix-sdk]
src/commands/devices.rs +2 −2
@@ -7,7 +7,7 @@ use matrix_sdk::identifiers::DeviceIdBox;
7use weechat::{ 7use weechat::{
8 buffer::Buffer, 8 buffer::Buffer,
9 hooks::{Command, CommandCallback, CommandSettings}, 9 hooks::{Command, CommandCallback, CommandSettings},
10 Args, Weechat, 10 Args, Prefix, Weechat,
11}; 11};
12 12
13use super::parse_and_run; 13use super::parse_and_run;
@@ -86,7 +86,7 @@ impl DevicesCommand {
86 } 86 }
87 _ => Weechat::print(&format!( 87 _ => Weechat::print(&format!(
88 "{}Subcommand isn't implemented", 88 "{}Subcommand isn't implemented",
89 Weechat::prefix("error") 89 Weechat::prefix(Prefix::Error)
90 )), 90 )),
91 } 91 }
92 } 92 }
src/commands/matrix.rs +2 −2
@@ -7,7 +7,7 @@ use url::Url;
7use weechat::{ 7use weechat::{
8 buffer::Buffer, 8 buffer::Buffer,
9 hooks::{Command, CommandCallback, CommandSettings}, 9 hooks::{Command, CommandCallback, CommandSettings},
10 Args, Weechat, 10 Args, Prefix, Weechat,
11}; 11};
12 12
13use super::parse_and_run; 13use super::parse_and_run;
@@ -174,7 +174,7 @@ Use /matrix [command] help to find out more.\n",
174 fn server_not_found(&self, server_name: &str) { 174 fn server_not_found(&self, server_name: &str) {
175 Weechat::print(&format!( 175 Weechat::print(&format!(
176 "{}{}: Server \"{}{}{}\" not found.", 176 "{}{}: Server \"{}{}{}\" not found.",
177 Weechat::prefix("error"), 177 Weechat::prefix(Prefix::Error),
178 PLUGIN_NAME, 178 PLUGIN_NAME,
179 Weechat::color("chat_server"), 179 Weechat::color("chat_server"),
180 server_name, 180 server_name,
src/commands/mod.rs +2 −2
@@ -6,17 +6,17 @@ use weechat::{
6 6
7use crate::{config::ConfigHandle, Servers}; 7use crate::{config::ConfigHandle, Servers};
8 8
9mod buffer_clear;
9mod devices; 10mod devices;
10mod keys; 11mod keys;
11mod matrix; 12mod matrix;
12mod page_up; 13mod page_up;
13mod buffer_clear;
14 14
15use buffer_clear::BufferClearCommand;
15use devices::DevicesCommand; 16use devices::DevicesCommand;
16use keys::KeysCommand; 17use keys::KeysCommand;
17use matrix::MatrixCommand; 18use matrix::MatrixCommand;
18use page_up::PageUpCommand; 19use page_up::PageUpCommand;
19use buffer_clear::BufferClearCommand;
20 20
21pub struct Commands { 21pub struct Commands {
22 _matrix: Command, 22 _matrix: Command,
src/render.rs +12 −10
@@ -20,7 +20,7 @@ use matrix_sdk::{
20 uuid::Uuid, 20 uuid::Uuid,
21}; 21};
22 22
23use weechat::Weechat; 23use weechat::{Prefix, Weechat};
24 24
25use crate::room::WeechatRoomMember; 25use crate::room::WeechatRoomMember;
26 26
@@ -173,7 +173,7 @@ impl Render for EmoteMessageEventContent {
173 type RenderContext = WeechatRoomMember; 173 type RenderContext = WeechatRoomMember;
174 174
175 fn prefix(&self, _: &WeechatRoomMember) -> String { 175 fn prefix(&self, _: &WeechatRoomMember) -> String {
176 Weechat::prefix("action").to_owned() 176 Weechat::prefix(Prefix::Action).to_owned()
177 } 177 }
178 178
179 fn render(&self, sender: &Self::RenderContext) -> RenderedContent { 179 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -195,7 +195,7 @@ impl Render for LocationMessageEventContent {
195 type RenderContext = WeechatRoomMember; 195 type RenderContext = WeechatRoomMember;
196 196
197 fn prefix(&self, _: &WeechatRoomMember) -> String { 197 fn prefix(&self, _: &WeechatRoomMember) -> String {
198 Weechat::prefix("action").to_owned() 198 Weechat::prefix(Prefix::Action).to_owned()
199 } 199 }
200 200
201 fn render(&self, sender: &Self::RenderContext) -> RenderedContent { 201 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -223,7 +223,7 @@ impl Render for NoticeMessageEventContent {
223 type RenderContext = WeechatRoomMember; 223 type RenderContext = WeechatRoomMember;
224 224
225 fn prefix(&self, _: &WeechatRoomMember) -> String { 225 fn prefix(&self, _: &WeechatRoomMember) -> String {
226 Weechat::prefix("action").to_owned() 226 Weechat::prefix(Prefix::Action).to_owned()
227 } 227 }
228 228
229 fn render(&self, sender: &Self::RenderContext) -> RenderedContent { 229 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -233,7 +233,7 @@ impl Render for NoticeMessageEventContent {
233 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}", 233 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}",
234 sender.nick.borrow(), 234 sender.nick.borrow(),
235 self.body, 235 self.body,
236 prefix = Weechat::prefix("network"), 236 prefix = Weechat::prefix(Prefix::Network),
237 color_notice = Weechat::color("irc.color.notice"), 237 color_notice = Weechat::color("irc.color.notice"),
238 color_delim = Weechat::color("chat_delimiters"), 238 color_delim = Weechat::color("chat_delimiters"),
239 color_reset = Weechat::color("reset"), 239 color_reset = Weechat::color("reset"),
@@ -253,7 +253,7 @@ impl Render for ServerNoticeMessageEventContent {
253 type RenderContext = WeechatRoomMember; 253 type RenderContext = WeechatRoomMember;
254 254
255 fn prefix(&self, _: &WeechatRoomMember) -> String { 255 fn prefix(&self, _: &WeechatRoomMember) -> String {
256 Weechat::prefix("action").to_owned() 256 Weechat::prefix(Prefix::Action).to_owned()
257 } 257 }
258 258
259 fn render(&self, sender: &Self::RenderContext) -> RenderedContent { 259 fn render(&self, sender: &Self::RenderContext) -> RenderedContent {
@@ -262,7 +262,7 @@ impl Render for ServerNoticeMessageEventContent {
262 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}", 262 {color_delim}({color_reset}{}{color_delim}){color_reset}: {}",
263 sender.nick.borrow(), 263 sender.nick.borrow(),
264 self.body, 264 self.body,
265 prefix = Weechat::prefix("network"), 265 prefix = Weechat::prefix(Prefix::Network),
266 color_notice = Weechat::color("irc.color.notice"), 266 color_notice = Weechat::color("irc.color.notice"),
267 color_delim = Weechat::color("chat_delimiters"), 267 color_delim = Weechat::color("chat_delimiters"),
268 color_reset = Weechat::color("reset"), 268 color_reset = Weechat::color("reset"),
@@ -472,9 +472,11 @@ pub fn render_membership(
472 } 472 }
473 473
474 let (prefix, color_action) = match change_op { 474 let (prefix, color_action) = match change_op {
475 Joined => ("join", "green"), 475 Joined => (Prefix::Join, "green"),
476 Banned | ProfileChanged { .. } | Invited => ("network", "magenta"), 476 Banned | ProfileChanged { .. } | Invited => {
477 _ => ("quit", "red"), 477 (Prefix::Network, "magenta")
478 }
479 _ => (Prefix::Quit, "red"),
478 }; 480 };
479 481
480 let color_action = Weechat::color(color_action); 482 let color_action = Weechat::color(color_action);
src/server.rs +3 −3
@@ -75,7 +75,7 @@ use matrix_sdk::{
75use weechat::{ 75use weechat::{
76 buffer::{BufferBuilder, BufferHandle}, 76 buffer::{BufferBuilder, BufferHandle},
77 config::{BooleanOptionSettings, ConfigSection, StringOptionSettings}, 77 config::{BooleanOptionSettings, ConfigSection, StringOptionSettings},
78 Weechat, 78 Prefix, Weechat,
79}; 79};
80 80
81use crate::{ 81use crate::{
@@ -794,12 +794,12 @@ impl InnerServer {
794 794
795 /// Print an network message to the server buffer. 795 /// Print an network message to the server buffer.
796 pub fn print_network(&self, message: &str) { 796 pub fn print_network(&self, message: &str) {
797 self.print_with_prefix(Weechat::prefix("network"), message); 797 self.print_with_prefix(&Weechat::prefix(Prefix::Network), message);
798 } 798 }
799 799
800 /// Print an error message to the server buffer. 800 /// Print an error message to the server buffer.
801 pub fn print_error(&self, message: &str) { 801 pub fn print_error(&self, message: &str) {
802 self.print_with_prefix(Weechat::prefix("error"), message); 802 self.print_with_prefix(&Weechat::prefix(Prefix::Error), message);
803 } 803 }
804 804
805 /// Is the server connected. 805 /// Is the server connected.