Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix cal day alignment for short day names #540

Merged
merged 2 commits into from
Oct 20, 2022
Merged

Conversation

hp-pepster
Copy link

If the day names do not consist of three characters, the alignment is off (see #522)

widget/cal.lua Outdated
@@ -53,6 +53,15 @@ local function factory(args)
return (x + y) % 7
end

function cal.get_dayname(day_num)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is not correct.

@lcpz
Copy link
Owner

lcpz commented Oct 18, 2022

Hi, thank you for your interest. I think it could be done just by using string.format. Something like this:

for x = 0, 6 do
    notifytable[#notifytable + 1] = string.format("%-3s ", os.date("%a",
    os.time { year = 2006, month = 1, day = x + cal.week_star }):sub(1, utf8.offset(1, 3))
end

Can you please test it? Plus, I admit that the code is a bit too compressed, so any reformatting is welcome.

EDIT: Also, if you can get rid of the utf8 dependency, that would solve #503 too.

@hp-pepster
Copy link
Author

I'll look into it after work. Seems like string.format() does not support right alignment, which leads to a strange format
grafik

If the day names do not consist of three characters, the alignment is off
(see lcpz#522).
@hp-pepster
Copy link
Author

I tested it on my system and also tested for this bug #476 which I assume was the reason for the utf-8 fix.

Maybe @Czarnodziej or @arielnmz can test if my commits don't break it again.

@Czarnodziej
Copy link
Contributor

Czarnodziej commented Oct 19, 2022

Looks good to me. Utf-8 names working properly with this commit on Lua 5.4.4

@lcpz lcpz merged commit 6cc8c92 into lcpz:master Oct 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants