~raphi/public-inbox

somebar: trim spaces from before layout icon v1 PROPOSED

Ben Collerson: 2
 trim spaces from before layout icon
 trim spaces from before layout icon

 2 files changed, 5 insertions(+), 1 deletions(-)
#889932 running archlinux.yml
#889933 running freebsd.yml



          
          
          
          
Next
Thanks!
To git.sr.ht:~raphi/somebar
   77c2c1d..6e464bf  master -> master
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~raphi/public-inbox/patches/37064/mbox | git am -3
Learn more about email & git

[PATCH somebar] trim spaces from before layout icon Export this patch

Not sure if this is the best way to do this. I noticed that a space was being included at the start of the layout icon text. My attempt to remove it.

diff --git a/src/main.cpp b/src/main.cpp
index 697909b..7b567e9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -326,6 +326,8 @@ static void handleStdin(const std::string& line)
               mon->tags = tags;
       } else if (command == "layout") {
               auto layout = std::string {};
               while (stream.peek() == ' ') // skip spaces
                       stream.get();
               std::getline(stream, layout);
               mon->bar.setLayout(layout);
       }
Wow, nice find!
Here's a shorter way: Replace your two new lines with
    stream >> std::ws;

This must also be done for the `if (command == "title")` block.

Raphi
This patch does not apply cleanly on top of current master, I assume you have other patches applied. Please rebase your patch on top of current master, and also use either `git format-patch` or `git send-email` [1] to create it. Otherwise the patch will not be attributed to you because it lacks your author information.

    Applying: trim spaces from before layout icon
    error: patch failed: src/main.cpp:300
    error: src/main.cpp: patch does not apply
    Patch failed at 0001 trim spaces from before layout icon

Raphi

[1] https://git-send-email.io/

Re: [PATCH somebar] trim spaces from before layout icon Export this patch

On Fri, 25 Nov 2022, at 01:53, Raphael Robatsch wrote:
> Wow, nice find!
> Here's a shorter way: Replace your two new lines with
>     stream >> std::ws;
>
> This must also be done for the `if (command == "title")` block.
>
> Raphi

Thanks. Here is a patch with the changes you suggested.

diff --git a/src/main.cpp b/src/main.cpp
index 697909b..6274959 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -300,7 +300,8 @@ static void handleStdin(const std::string& line)
               return;
       if (command == "title") {
               auto title = std::string {};
               std::getline(stream, title);
               stream >> std::ws;
               std::getline(stream, title);
               mon->bar.setTitle(title);
       } else if (command == "selmon") {
               uint32_t selected;
@@ -326,6 +327,7 @@ static void handleStdin(const std::string& line)
               mon->tags = tags;
       } else if (command == "layout") {
               auto layout = std::string {};
               stream >> std::ws;
               std::getline(stream, layout);
               mon->bar.setLayout(layout);
       }