Skip to content

Commit

Permalink
Merge pull request #12 from Shizcow/develop
Browse files Browse the repository at this point in the history
Merge for release 5.2.3
  • Loading branch information
Shizcow authored Jul 2, 2020
2 parents ed9fdd9 + 3493cbe commit 449b98b
Show file tree
Hide file tree
Showing 7 changed files with 752 additions and 44 deletions.
705 changes: 674 additions & 31 deletions LICENSE

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ plugin support; read below.
dmenu-rs leverages rust crates `overrider` and `proc_use` to provide an easy to
write and powerful plugin system. The end-result are plugins which are dead-simple
to enable.
For more info on enabling plugins, run `make plugins`.
For a list of available plugins and more info on
enabling plugins, run `make plugins`.
For more info on developing plugins, read the [plugin guide](src/plugins/README.md).

## Requirements
Expand All @@ -37,12 +38,14 @@ For more info on developing plugins, read the [plugin guide](src/plugins/README.
Edit config.mk to match your local setup (dmenu is installed into
the /usr/local namespace by default).

Afterwards enter the following command to build and install dmenu
(if necessary as root):
```make clean install```
Afterwards enter the following command to build dmenu:
```make```
Then, to install (if necessary as root):
```make install```
### Distros
dmenu-rs is available from the following sources:
- [Arch AUR](https://aur.archlinux.org/packages/dmenu-rs/)
- [Arch AUR - stable branch](https://aur.archlinux.org/packages/dmenu-rs/)
- [Arch AUR - development branch](https://aur.archlinux.org/packages/dmenu-rs-git/)

If you'd like for this to be available on another distro, raise an issue
or submit a pull request with a README change pointing to the released
Expand Down
2 changes: 1 addition & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = 5.2.2
VERSION = 5.2.3

# paths
PREFIX = /usr/local
Expand Down
59 changes: 59 additions & 0 deletions src/config/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ pub fn get_yaml(file: &str) -> Yaml {
YamlLoader::load_from_str(&yaml_str).unwrap().swap_remove(0)
}



#[allow(unused)]
pub fn get_yaml_top_level<'a>(yaml: &'a mut Yaml, fieldsearch: &str) -> Option<&'a mut String> {
match yaml {
Expand Down Expand Up @@ -61,6 +63,7 @@ pub fn get_yaml_args(yaml: &mut Yaml) -> &mut Vec<yaml::Yaml> {
if fieldname == "args" {
match field.1 {
Yaml::Array(arr) => {
sanitize_args(arr);
return arr;
},
_ => panic!("Incorrect arg format on cli_base"),
Expand All @@ -73,3 +76,59 @@ pub fn get_yaml_args(yaml: &mut Yaml) -> &mut Vec<yaml::Yaml> {
}
panic!("No args found in yaml object");
}

fn sanitize_args(args: &mut Vec<yaml::Yaml>) {
*args = args.drain(..).map(|yml| {
if let Yaml::Hash(mut hash) = yml {
for (_, arg) in hash.iter_mut() {
if let Yaml::Hash(ref mut properties) = arg {
let name_visible_aliases = Yaml::String("visible_aliases" .to_owned());
let name_visible_short_aliases = Yaml::String("visible_short_aliases".to_owned());
let visible_aliases = properties.remove(&name_visible_aliases);
let visible_short_aliases = properties.remove(&name_visible_short_aliases);

let mut alias_help = Vec::new();

if let Some(Yaml::String(visible_aliases)) = visible_aliases {
let name_aliases = Yaml::String("aliases".to_owned());
let aliases = properties.remove(&name_aliases);
let mut new_aliases = visible_aliases;
if let Some(Yaml::String(aliases)) = aliases {
new_aliases.push(' ');
new_aliases.push_str(&aliases);
};
for alias in new_aliases.split(' ') {
alias_help.push(format!("--{}", alias));
}
properties.insert(name_aliases, Yaml::String(new_aliases));
}

if let Some(Yaml::String(visible_short_aliases)) = visible_short_aliases {
let name_short_aliases = Yaml::String("short_aliases" .to_owned());
let short_aliases = properties.remove(&name_short_aliases);
let mut new_short_aliases = visible_short_aliases;
if let Some(Yaml::String(short_aliases)) = short_aliases {
new_short_aliases.push(' ');
new_short_aliases.push_str(&short_aliases);
};
for alias in new_short_aliases.split(' ') {
alias_help.push(format!("-{}", alias));
}
properties.insert(name_short_aliases, Yaml::String(new_short_aliases));
}

if !alias_help.is_empty() {
let alias_string = format!("\n [aliases: {}]", alias_help.join(", "));
if let Some(Yaml::String(ref mut long_help)) = properties.get_mut(&Yaml::String("long_help".to_owned())).as_mut() {
long_help.push_str(&alias_string);
} else if let Some(Yaml::String(ref mut help)) = properties.get_mut(&Yaml::String("help".to_owned())).as_mut() {
help.push_str(&alias_string);
}
}
}
}
return Yaml::Hash(hash);
}
yml
}).collect();
}
10 changes: 5 additions & 5 deletions src/dmenu/cli_base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ args:
value_name: PROMPT
- font:
help: Add menu font
long_help: "Add menu font. Can be specified multiple times to give fallback fonts.\
For example, --font Terminus --font 'Font Awesome' would draw everything\
long_help: "Add menu font. Can be specified multiple times to give fallback fonts. \
For example, --font Terminus --font 'Font Awesome' would draw everything \
with Terminus, and fall back to Font Awesome for symbols.\n\
If a glyph is not found in any of the supplied fonts, it will be provided\
If a glyph is not found in any of the supplied fonts, it will be provided \
by the default font (:mono). \n\
If a glyph is not found in any fonts, it will\
If a glyph is not found in any fonts, it will \
render as the no-character box."
long: font
aliases: fn
visible_aliases: fn
takes_value: true
value_name: FONT
multiple: true
Expand Down
3 changes: 2 additions & 1 deletion src/dmenu/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ impl Drw {
}
/* no focused window is on screen, so use pointer location instead */
if self.config.mon < 0 && area == 0 && XQueryPointer(self.dpy, root, &mut dw, &mut dw, &mut x, &mut y, &mut di, &mut di, &mut du) != 0 {
for i in 0..n {
for j in 0..n {
i = j; // this is here to bypass rust's shadowing rules in an efficient way
if intersect(x, y, 1, 1, info.offset(i as isize)) != 0 {
break;
}
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,9 @@ For each field:
- cargo_dependencies: This field is optional. If additional crate dependencies are required,
this field points to this file.
- args: These are command line arguments. They have the same syntax as arguments for `clap`,
and are more or less copy-pasted into a `cli.yml` file down the line.
and are more or less copy-pasted into a `cli.yml` file down the line.
Support for `visible_aliases` has been added in, so these work out of the box while `clap`
does not yet support them.

### main.rs
This file's actual name is set by the `entry` field in `plugin.yml`.
Expand Down

0 comments on commit 449b98b

Please sign in to comment.