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

Add ability to do leading spaces with ColumnEditor #13336

Closed
wants to merge 3 commits into from

Conversation

alankilborn
Copy link
Contributor

@alankilborn alankilborn commented Mar 11, 2023

Fix #11148 ; fix #13309 .

@alankilborn
Copy link
Contributor Author

Second commit changes nbChiffre to a more readable nbDigits; if this is not wanted, easy to separate out.

@alankilborn
Copy link
Contributor Author

Tested the PR code:

none               |  zeros              |  spaces
0   0   0   0      |  00  00  00  00000  |   0   0   0      0
1   1   1   1      |  01  01  01  00001  |   1   1   1      1
2   2   2   10     |  02  02  02  00010  |   2   2   2     10
3   3   3   11     |  03  03  03  00011  |   3   3   3     11
4   4   4   100    |  04  04  04  00100  |   4   4   4    100
5   5   5   101    |  05  05  05  00101  |   5   5   5    101
6   6   6   110    |  06  06  06  00110  |   6   6   6    110
7   7   7   111    |  07  07  07  00111  |   7   7   7    111
8   8   10  1000   |  08  08  10  01000  |   8   8  10   1000
9   9   11  1001   |  09  09  11  01001  |   9   9  11   1001
10  A   12  1010   |  10  0A  12  01010  |  10   A  12   1010
11  B   13  1011   |  11  0B  13  01011  |  11   B  13   1011
12  C   14  1100   |  12  0C  14  01100  |  12   C  14   1100
13  D   15  1101   |  13  0D  15  01101  |  13   D  15   1101
14  E   16  1110   |  14  0E  16  01110  |  14   E  16   1110
15  F   17  1111   |  15  0F  17  01111  |  15   F  17   1111
16  10  20  10000  |  16  10  20  10000  |  16  10  20  10000

@Yaron10
Copy link

Yaron10 commented Mar 12, 2023

@alankilborn,

Very nice. 👍
Thank you for your work.


Just another interesting case (NOT caused by this PR):
If you select a virtual column and insert text via the column-editor, the post-operation-selection is wrong.

@alankilborn
Copy link
Contributor Author

the post-operation-selection is wrong.

That was noticed, but since it wasn't related to the change, I didn't worry about it.
The code change is already VERY large, with large risk of rejection on that basis.
(I finished this some time ago, but held back, and wasn't going to submit at all, given the amount of change for such small gain. Then I decided that the risk was worth it, to potentially provide users with the improvement)

@donho donho self-assigned this Mar 12, 2023
Copy link
Member

@donho donho left a comment

Choose a reason for hiding this comment

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

Please follow the suggestions.

PowerEditor/installer/nativeLang/english.xml Outdated Show resolved Hide resolved
PowerEditor/src/Parameters.h Outdated Show resolved Hide resolved
PowerEditor/src/ScintillaComponent/ScintillaEditView.h Outdated Show resolved Hide resolved
PowerEditor/src/ScintillaComponent/columnEditor_rc.h Outdated Show resolved Hide resolved
@Yaron10
Copy link

Yaron10 commented Mar 18, 2023

@alankilborn,

If the last selected section is "Text", we have "number" in config.xml. And vice-versa.

if (lstrcmp(strVal, TEXT("text")) == 0)

(columnEditorRootNode.ToElement())->SetAttribute(TEXT("choice"), _columnEditParam._mainChoice ? L"number" : L"text");

It seems the values should be swapped.
Should I open a new issue?

@alankilborn
Copy link
Contributor Author

@Yaron10

If the last selected section is "Text", we have "number" in config.xml. And vice-versa.
It seems the values should be swapped.
Should I open a new issue?

I'd say a resounding YES!

@Yaron10
Copy link

Yaron10 commented Mar 18, 2023

#13370.

@alankilborn
Copy link
Contributor Author

@donho, if it builds (still building as I type this), then this PR is ready for re-review.

@@ -57,7 +57,15 @@ intptr_t CALLBACK ColumnEditorDlg::run_dlgProc(UINT message, WPARAM wParam, LPAR
::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("None")));
::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Zeros")));
::SendDlgItemMessage(_hSelf, IDC_COL_LEADING_COMBO, CB_ADDSTRING, 0, reinterpret_cast<LPARAM>(TEXT("Spaces")));
::SendMessage(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), CB_SETCURSEL, colEditParam._leadingChoice, 0);
WPARAM curSel = 0;
Copy link

Choose a reason for hiding this comment

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

May I ask why this block is necessary?
Can't leadingChoice be int?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Don wanted the "leading choice" to be an enum (see Don's prior comments). My goal here was to fully uncouple things. Again, I can't read Don's mind as to how "far" to take such things, so I proceeded on the presumption of this type of decoupling being wanted. I really have no idea. If the future gets "sticky" for me on this PR, I will abandon it and close it; of course an outright rejection will do that just as well, also. :-)

Copy link

Choose a reason for hiding this comment

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

Don wanted the "leading choice" to be an enum

I meant to ask why the enum couldn't be int. :)

Well, let's for Don's review.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yea, the way I read it was Don specifically wanted enum.
But maybe his real intent was to just not have two bool. I do understand the desire to not have two bool; indeed I only went with 2 bool in the beginning in an effort to change as little as possible.
The high volume of changed lines in this makes me uncomfortable -- not at a C++ level, but at a "this is someone else's project" level.
I see others aren't afraid to change a lot of lines; I think a lot of changes are more acceptable if the feature is really wanted.
I'm truly sorry that I got involved in this one; my intent was to stay with smaller changes.

Copy link

Choose a reason for hiding this comment

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

I'm glad you got involved in this one. - You did a great job. 👍
I'm sorry you didn't enjoy working on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main question was why the switch (colEditParam._leadingChoice) block was necessary.

"Necessary" might be a strong word, here. :-)
We can do things in a "hacky" way, and sure, that has been done in the past.

The code (that I think) you are questioning was changed to fully decouple the integer values of the combobox selection indices and the "values" of the enum type.

With this, the code for this line:
enum leadingChoice : UCHAR { noneLeading, zeroLeading, spaceLeading };
could be changed to this without any runtime difference:
enum leadingChoice : UCHAR { noneLeading=27, zeroLeading=45, spaceLeading=106 };

(Probably the UCHAR should be eliminated; this is a carryover of my habit because I work on smallish embedded systems where every byte can matter.)

Don seemed to want an enum ; when he requested this change, I provided, in a better and more complete fashion than an earlier commit (earlier commits aren't really relevant when changes are requested and made).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@donho

Edit: oups, I misread your comment. Good job, it's what it needs.

Thank you, Don, encouragement to your contributors that they are doing the right thing is very helpful indeed!

Copy link

Choose a reason for hiding this comment

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

@alankilborn,

Thank you for the explanation. 👍
You're a very good coder, and I was trying to understand and learn your approach.

Copy link
Member

Choose a reason for hiding this comment

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

@Yaron10
It's true that I (as a lazy dev) I would do the following without switch:

enum leadingChoice { noneLeading = 0, zeroLeading = 1, spaceLeading = 2};
::SendMessage(::GetDlgItem(_hSelf, IDC_COL_LEADING_COMBO), CB_SETCURSEL, (WPARAM)colEditParam._leadingChoice, 0);

The @alankilborn 's way guarantees strongly the value must be "> 3" & "<= 0".
As I always check both side while crossing the one way road IRL, I can understand his approach - and since it's not redundant, it's OK to me.

Copy link

Choose a reason for hiding this comment

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

@donho,

The "lazy approach" was what I had in mind.
Thank you for the detailed explanation. 👍

@donho donho added the accepted label Mar 21, 2023
@Yaron10
Copy link

Yaron10 commented Mar 24, 2023

@alankilborn,

If the Format is Hex, Initial Number is 999 and Increase is blank - you always get 4 characters.
If Initial Number is 99, you get 2 characters.

What do you think?

@alankilborn
Copy link
Contributor Author

If the Format is Hex, Initial Number is 999 and Increase is blank - you always get 4 characters. If Initial Number is 99, you get 2 characters.

What do you think?

if ((base == 16) && (nbChiffre % 2 != 0))
nbChiffre += 1;

If the hex number needs an odd number of digits for display, it is increased to the next even number of digits -- no idea why this would be this way; this PR isn't related.

@Yaron10
Copy link

Yaron10 commented Mar 24, 2023

@alankilborn,

Yes, it's not related to this PR.
But it is related to #11148 (comment), and I thought that mini-discussion was held here.

Thank you.

@alankilborn
Copy link
Contributor Author

But it is related to 11148, and I thought that mini-discussion was held here.

I reread that now and I'm so confused.
Is THAT relevant to current issue and PR?
If not, it needs to be a separate issue, to avoid confusion.

@Yaron10
Copy link

Yaron10 commented Mar 24, 2023

You asked for my opinion in that thread, and I raised that point as a side-note.
Sorry for the confusion.

@alankilborn
Copy link
Contributor Author

alankilborn commented Mar 24, 2023

I raised that point as a side-note.

OK... I don't think the current issue and PR can/should be a catch-all to all wacky behavior with Column Editor. I think current issue and PR should address the basic deficiency (of not currently -- 8.5.1 -- being able to insert numbers with leading spaces) and that other behavior should be addressed separately. I suggest waiting until this PR is integrated/rejected and then making issues on further defects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Column Editor > Insert Number drops binary zero "Leading blanks" option to Column / Multi-Selection Editor
3 participants