Comments (3)
I'll get back to it soon.
from nwg-drawer.
I wrote two functions to correct the behavior:
func parseString(s string) []string {
var r = regexp.MustCompile(`(".*"|(\\\s|[^\s])+)`)
var res = r.FindAllString(s, -1)
return res
}
func parseString2(command string) []string {
var elements []string
var confirmed []string
if !strings.Contains(command, "\"") {
elements = append(elements, strings.Split(command, " ")...)
} else {
for strings.Contains(command, "\"") {
quoteSplit := strings.SplitN(command, "\"", 2)
elements = append(elements, strings.Split(quoteSplit[0], " ")...)
quoteSplit = strings.SplitN(quoteSplit[1], "\"", 2)
elements = append(elements, quoteSplit[0])
command = quoteSplit[1]
}
}
for i := 0; i < len(elements); i++ {
if elements[i] != "" { // Ignore empty arguments
element := elements[i]
// If the argument end with "\ " then merge with next argument
for element[len(element)-1] == '\\' {
element = strings.Replace(element, "\\", "", 1)
element = element + " " + elements[i+1]
i++
}
confirmed = append(confirmed, element)
}
}
return confirmed
}
Both seem to work fine in my testing but checking edge cases may be necessary, I don't like the second one as it is a little convoluted but running benchmarks proved that it is much faster than the regex option.
from nwg-drawer.
I also encountered this issue in nwg-menu. This seems important!
from nwg-drawer.
Related Issues (20)
- Dead icons in nwg-drawer HOT 5
- Dotted lines not in drawer.css HOT 3
- nwg-drawer send string to search from command line HOT 5
- Can't click on waybar when nwg-drawer is open HOT 3
- Issues on touch devices HOT 3
- feature: power options HOT 7
- support appimage , it will run X11 or way HOT 1
- Respect XDG_DATA_DIRS HOT 1
- switch to gtk4 and libadwaita
- Detect WM with $XDG_CURRENT_DESKTOP ? HOT 1
- How do I detect if the drawer is showing? HOT 2
- Use power/reset/exit icons from theme if .svg are unavailable HOT 6
- Is it possible to use touchscreen to scroll? HOT 1
- It seems that the spaces in the command line options are not being handled properly.
- Launching thunar from nwg-drawer opens in sway config directory HOT 2
- feature: prefer most used applications HOT 1
- Add CI HOT 2
- Launching certain apps HOT 10
- Change term overriding variable and improve error handling? HOT 4
- Some icons appear smaller and are offset when searching HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nwg-drawer.