News:

Download Pelles C here: http://www.smorgasbordet.com/pellesc/

Main Menu

Line Counter Add-IN

Started by John Z, May 17, 2021, 04:00:50 PM

Previous topic - Next topic

John Z

Here is version 1.7.7 of an Add-In for PellesC (of course).
This Add-In is a Line counter. I saw a forum member ask for one.
The Add-In will be a menu item under the main menu 'Source.' It
will show as "Line Counts +".

It will do more than just line counting. You can get the line number for each user procedure.  You can also get list of all user procedures called from within each user procedure.  BTW the user procedure determination is independent and not using the treeview information from the project window.

John Z

Update 6/24 - The attachment here is the latest version 1.7.5 to make it easy  :)
Update 7/6/2023 - The attachment here is the Pelles C V12.002 build to version 1.7.6
Update 8/14/2023 - The attachment here is the Pelles C V12.002 build to version 1.7.6.1
Update 11/01/2023 - The attachment on page 6 is the Pelles C V12.002 build to version 1.7.7

Grincheux

I have loaded your addin but I can't see any line. :-[

John Z

perhaps a step wise instruction
1) Close PellesC
2) Copy the dll into the "Bin" folder subfolder "Addins64"
3) Open PellesC
4) Click 'Tools'
5) Click 'Customize'
6) Click 'Add-Ins' tab
7) Check box next to "PellesC Line Counte Add-In"  (I see typo)
8) Click OK

Steps 1-8 only need to be done the first time

9) Open a PellesC project file
10) Select a source .C file
11) Click Menu 'Source'
12) Click 'Line Counts'   - Should be there ;) like attached screen shot

13) See results in Output tab

John Z

Grincheux

QuoteFile name:C:\Users\51966\OneDrive\Documents\Pelles C Projects\Essai\Start.asm
startLine:90, endLine:93
Total Lines: 4
Empty Lines: 1
Code Lines: 3


With my current ASM Project

Grincheux

Tested on CFE project


QuoteFile name:C:\Users\51966\OneDrive\Documents\Pelles C Projects\Cfe\Cfe.c
startLine:0, endLine:5946
Total Lines: 5946
Empty Lines: 1076
Lone {: 350
Lone {: 348
Comment Lines: 8
Continuations: 139
Code Lines: 4025

John Z

Great! I know it's not detecting asm comment lines .... might be worth adding. I'll look at your attachment.  Was targeting C code originally.

Thanks for trying it.


John Z

frankie

Quote from: John Z on May 17, 2021, 04:00:50 PM
File name:C:\Program Files\PellesC\Files\LCounter\Line_Count.c
startLine:0, endLine:371
Total Lines: 371
Empty Lines: 44
Lone {: 15
Lone {: 26
Comment Lines: 103
Continuations: 1
Code Lines: 182

Shouldn't be: "Total Lines: 372" ?  ???
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

John Z

Thanks Frankie,

Well... there are actually 371 lines when I use the cursor in the file. The discrepancy, if any, might be in saying the start is line 0. PellesC edit window shows that to be line 1.  I'll double check though when I fix the typos, one of which was the second output { line which should have been lone } (close bracket).

The TrimTail code had these lines for the full page:
iFirstLine = 0;
iLastLine = AddIn_GetSourceLineCount(hwndDoc) - 1;


So it appears to get line 1 you start with line 0, and the last line which is the required PellesC closing CRLF is not included.

The sum of the processed lines also adds up to the 371.

I'll look further though :)

Thanks for the inputs,

John Z

Grincheux

In C you search for '{' and '}', in asm search for 'PROC' and 'ENDP'.

John Z

#9
Version 0.2
Fixed text typos, fixed line start when processing entire source file, fixed line end when processing a selected block of source code.  Added some error reporting, added a count and warning of long lines > 4095 characters when found.

Haven't looked at processing asm specifically yet....

John Z

Grincheux

It was version 1.0 before and now 0.2!
For the asm I will wait, perhaps one day >:( >:( >:(

John Z

 :)
it was version 0.1 before .... shouldn't version 1.0 be the first 'official' release?   ;D

I think asm line count needs different groupings, like .data, .code, comments, label lines, etc so will need to check extension and change processing based on the file type.


Cheers,

John Z



John Z

#12
Version 0.3 for testing
This version adds in ASM specific line binning when the file extension is .asm

Question:  Should it clear the output window before showing results?

Example Output:
File name:C:\Program Files\PellesC\Files\Essai\Start.asm
startLine:1, endLine:118
Total Lines: 118
Empty Lines: 27
Data : 4
Labels  : 5
Comment Lines: 22
Code Lines: 60


I'll post the code soon.  I think it is almost done, I know it is not and probably never will be a high use add-in but it was a good one for me to gain experience on.

John Z

Grincheux

#13
QuoteQuestion:  Should it clear the output window before showing results?


YES

I have installed the add-in but I don't see annythig for a '.c' file and a '.asm' file.
I made a wrong thing but which one?

John Z

QuoteQuestion:  Should it clear the output window before showing results?
QuoteYES
Thanks I'll add the clear.
Quote
I have installed the add-in but I don't see anything for a '.c' file and a '.asm' file.
I made a wrong thing but which one?

The determination of .asm or .c (where really is anything but .asm) is within the code by looking at the file extension.  The user does not select C or ASM directly.

Looks like your post was hit with the Notepad++ bug but I was able to read it by using quote :)

Thanks,

John Z