Skip to content

Commit

Permalink
ct 0.32 - now in tree with * get all declares plus minor things
Browse files Browse the repository at this point in the history
  • Loading branch information
some-avail committed May 24, 2024
1 parent e175c2f commit c9f0a2f
Show file tree
Hide file tree
Showing 9 changed files with 248 additions and 15 deletions.
45 changes: 30 additions & 15 deletions mostfiles/ctwig.nim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import std/[os, strutils, paths, dirs, tables, parseopt]


var
versionfl: float = 0.31
versionfl: float = 0.32
codetwigst: string = "CodeTwig"
ct_projectsdirst: string = "projects"
dec_list_suffikst: string = "dec_list.dat"
Expand Down Expand Up @@ -452,7 +452,7 @@ proc createDeclarationList(proj_def_pathst: string) =
if sline.strip().startswith("#"): singlecommentbo = true

if sline.len > 2 and not incommentblockbo and not commentclosingbo and not singlecommentbo:
if sline.contains(declare2st):
if sline.contains(declare2st) and not sline.contains("\"" & declare2st & "\""):
foundcountit += 1
if not (dec_plus_modulest in unique_decplusmodule2sq):
unique_decplusmodule2sq.add(dec_plus_modulest)
Expand Down Expand Up @@ -621,6 +621,13 @@ proc createCodeViewFile(proj_def_pathst: string, viewtypeeu: ViewType) =
proc getSeqFromFileLines(filepathst, searchst, sep1st, sep2st: string, searchfieldar: array[0..1, int], substringbo: bool = true): seq[string] =

#[
Add lines to the sequence which match the search-filter.
Search with substring, string or wildcard * for search-value searchst on designated search-field, which is indicated by the coordinates on the sep-divided line.
Like so:
part-a1~~~parta2===partb1~~~partb2
part-b2 = [1,1]
extra separator and sortfieldar may come later
]#

Expand All @@ -634,13 +641,16 @@ proc getSeqFromFileLines(filepathst, searchst, sep1st, sep2st: string, searchfie

for linest in fileob.lines:
searchfieldvalst = linest.split(sep1st)[searchfieldar[0]].split(sep2st)[searchfieldar[1]]
#echo searchfieldvalst & "-----" & searchst
if substringbo:
if searchfieldvalst.toLowerAscii.contains(searchst.toLowerAscii):
outputsq.add(linest)
else:
if searchfieldvalst.toLowerAscii == searchst.toLowerAscii:
outputsq.add(linest)
if searchst == "*": # get all decs
outputsq.add(linest)
else:
#echo searchfieldvalst & "-----" & searchst
if substringbo:
if searchfieldvalst.toLowerAscii.contains(searchst.toLowerAscii):
outputsq.add(linest)
else:
if searchfieldvalst.toLowerAscii == searchst.toLowerAscii:
outputsq.add(linest)

fileob.close()
result = outputsq
Expand Down Expand Up @@ -794,7 +804,6 @@ proc showDeclarationBranch(proj_def_pathst, directionst: string, maxdepthit: int
#[
Show a tree of declarations; either a usage-tree or a used-by-tree.
Later: , declarationst, directionst: string, depthit: int
]#

var
Expand Down Expand Up @@ -823,7 +832,7 @@ proc showDeclarationBranch(proj_def_pathst, directionst: string, maxdepthit: int

echo "--------------------------------------------------------"
echo "Direction (tree-type) = ", directionst, ", Maxdepth = ", maxdepthit
echo "Enter the declaration you want to view, or exit to exit: "
echo "Enter the declaration you want to view, * for all , or exit to exit: "
decfilepathst = string(Path(reltargetprojectpathst) / Path(string(pd_filebasepa)[0..6] & "_phase3_" & dec_list_suffikst))

decfilob = open(decfilepathst, fmRead)
Expand All @@ -832,9 +841,13 @@ proc showDeclarationBranch(proj_def_pathst, directionst: string, maxdepthit: int
while not(inputst in ["exit","quit"]):
inputst = readline(stdin)
foundlinesq = getSeqFromFileLines(decfilepathst, inputst, sep3st, sep1st, [0,0], false)
if foundlinesq.len == 0:
# maybe find something with substring-search
foundsublinesq = getSeqFromFileLines(decfilepathst, inputst, sep3st, sep1st, [0,0])
# if no match found or wildcard * used (all found):
if foundlinesq.len == 0 or foundlinesq.len > 1:
if foundlinesq.len == 0:
# maybe find something with substring-search
foundsublinesq = getSeqFromFileLines(decfilepathst, inputst, sep3st, sep1st, [0,0])
else:
foundsublinesq = foundlinesq
if foundsublinesq.len > 1:
#echo foundlinesq
echo "========================================================================="
Expand Down Expand Up @@ -1082,7 +1095,9 @@ else:
if false:
createCodeViewFile(filepathst, viewBasic_OneLevel)
createCodeViewFile(filepathst, viewBasic_TwoLevels)
if true:
if false:
echo getSeqFromFileLines(filepathst, "*", "===" , "~~~", [0,0], true).len
if false:
showDeclarationBranch(filepathst, "usage", 3)
#showDeclarationBranch(filepathst, "used-by", 5)

3 changes: 3 additions & 0 deletions mostfiles/manual_codetwig.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
When reading from Github, press button "Raw" to get line-wrapping.
------------------------------------------------------------------

Welcome to help for CodeTwig

CodeTwig is terminal-program to view source-code and to show procedures as usage-trees or used-by-trees.
Expand Down
34 changes: 34 additions & 0 deletions mostfiles/projects/codetwig.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
CodeTwig can create special views of your programming-projects.

Create your project-file below,
if you want to be able to show code-trees for the project.

The project-path is the base-path for the project,
either as absolute path or
as relative path from the ctwig-executable
(CT will know which).

The source-files can be entered programmatically,
as well as manually.
(for now only one dir-level of files can be used)




FILE_EXTENSIONS (leave: not yet used; for now only nim)
nim
>----------------------------------<



PROJECT_PATH
/media/OnsSpul/1klein/1joris/k1-onderwerpen/computer/Programmeren/nimtaal/codetwig/mostfiles
>----------------------------------<



SOURCE_FILES
ctwig.nim
g_disk2nim.nim
g_templates.nim
>----------------------------------<
28 changes: 28 additions & 0 deletions mostfiles/projects/codetwig/codetwi_basic_one-level_view.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
ctwig---------------------------------------------------
extractFileSectionToSequence proc line: 114
getSliceFromAnchor proc line: 137
countLinesOfFile proc line: 211
createDeclarationList proc line: 224
createCodeViewFile proc line: 504
getSeqFromFileLines proc line: 621
getSeqFromLinesSpecial proc line: 680
writeFamily proc line: 727
showDeclarationBranch proc line: 802
echoHelpInfo proc line: 902
createAllViewFiles proc line: 948
generate_all proc line: 955
processCommandLine proc line: 963
g_disk2nim---------------------------------------------------
writeFilePatternToSeq proc line: 18
getPatternLocation proc line: 40
writeFilePatternToSeq2 proc line: 66
addShowValuesToSeq proc line: 116
convertFileToSequence proc line: 136
convertMultFilesToSeq proc line: 159
g_templates---------------------------------------------------
withFileAdvanced template line: 18
doWork proc line: 45
timeStuff template line: 51
timeThings template line: 57
timeNeatly template line: 65
timeCop template line: 71
52 changes: 52 additions & 0 deletions mostfiles/projects/codetwig/codetwi_basic_two-level_view.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ctwig--------------------------------------------------------------------
extractFileSectionToSequence proc line: 114
withFile g_templates template 125
withFileAdvanced g_templates template 125
getSliceFromAnchor proc line: 137
countLinesOfFile proc line: 211
createDeclarationList proc line: 224
extractFileSectionToSequence ctwig proc 281
getSliceFromAnchor ctwig proc 333
countLinesOfFile ctwig proc 390
createCodeViewFile proc line: 504
extractFileSectionToSequence ctwig proc 528
getSeqFromFileLines proc line: 621
getSeqFromLinesSpecial proc line: 680
writeFamily proc line: 727
getSeqFromFileLines ctwig proc 756
getSeqFromLinesSpecial ctwig proc 771
writeFamily ctwig proc 767
showDeclarationBranch proc line: 802
extractFileSectionToSequence ctwig proc 826
getSeqFromFileLines ctwig proc 843
writeFamily ctwig proc 866
echoHelpInfo proc line: 902
createAllViewFiles proc line: 948
createCodeViewFile ctwig proc 950
generate_all proc line: 955
createDeclarationList ctwig proc 957
createAllViewFiles ctwig proc 958
processCommandLine proc line: 963
addSourceFilesToProject ctwig proc 1027
createDeclarationList ctwig proc 1029
showDeclarationBranch ctwig proc 1035
echoHelpInfo ctwig proc 1037
createAllViewFiles ctwig proc 1031
generate_all ctwig proc 1033
g_disk2nim--------------------------------------------------------------------
writeFilePatternToSeq proc line: 18
getPatternLocation proc line: 40
writeFilePatternToSeq2 proc line: 66
getPatternLocation g_disk2nim proc 81
addShowValuesToSeq proc line: 116
convertFileToSequence proc line: 136
withFile g_templates template 144
convertMultFilesToSeq proc line: 159
withFile g_templates template 169
g_templates--------------------------------------------------------------------
withFileAdvanced template line: 18
doWork proc line: 45
timeStuff template line: 51
timeThings template line: 57
timeNeatly template line: 65
timeCop template line: 71
43 changes: 43 additions & 0 deletions mostfiles/projects/codetwig/codetwi_phase1_dec_list.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
other_declaration~~~ctwig~~~import g_disk2ni~~~ls:15
other_declaration~~~ctwig~~~import std/[os, ~~~ls:17
other_declaration~~~ctwig~~~var ~~~ls:20
other_declaration~~~ctwig~~~type ~~~ls:26
addSourceFilesToProject~~~ctwig~~~proc~~~ls:35~~~cs:5~~~ce:27
extractFileSectionToSequence~~~ctwig~~~proc~~~ls:114~~~cs:5~~~ce:32
getSliceFromAnchor~~~ctwig~~~proc~~~ls:137~~~cs:5~~~ce:22
countLinesOfFile~~~ctwig~~~proc~~~ls:211~~~cs:5~~~ce:20
createDeclarationList~~~ctwig~~~proc~~~ls:224~~~cs:5~~~ce:25
createCodeViewFile~~~ctwig~~~proc~~~ls:504~~~cs:5~~~ce:22
getSeqFromFileLines~~~ctwig~~~proc~~~ls:621~~~cs:5~~~ce:23
getSeqFromLinesSpecial~~~ctwig~~~proc~~~ls:680~~~cs:5~~~ce:26
writeFamily~~~ctwig~~~proc~~~ls:727~~~cs:5~~~ce:15
showDeclarationBranch~~~ctwig~~~proc~~~ls:802~~~cs:5~~~ce:25
echoHelpInfo~~~ctwig~~~proc~~~ls:902~~~cs:5~~~ce:16
createAllViewFiles~~~ctwig~~~proc~~~ls:948~~~cs:5~~~ce:22
generate_all~~~ctwig~~~proc~~~ls:955~~~cs:5~~~ce:16
processCommandLine~~~ctwig~~~proc~~~ls:963~~~cs:5~~~ce:22
other_declaration~~~ctwig~~~var for_realbo: ~~~ls:1066
other_declaration~~~ctwig~~~if for_realbo:~~~ls:1067
other_declaration~~~g_disk2nim~~~import strutils,~~~ls:4
other_declaration~~~g_disk2nim~~~import os~~~ls:5
other_declaration~~~g_disk2nim~~~import g_templat~~~ls:6
other_declaration~~~g_disk2nim~~~var versionfl: f~~~ls:8
other_declaration~~~g_disk2nim~~~var debugbo: boo~~~ls:9
log~~~g_disk2nim~~~template~~~ls:11~~~cs:9~~~ce:11
writeFilePatternToSeq~~~g_disk2nim~~~proc~~~ls:18~~~cs:5~~~ce:25
getPatternLocation~~~g_disk2nim~~~proc~~~ls:40~~~cs:5~~~ce:22
writeFilePatternToSeq2~~~g_disk2nim~~~proc~~~ls:66~~~cs:5~~~ce:26
addShowValuesToSeq~~~g_disk2nim~~~proc~~~ls:116~~~cs:5~~~ce:22
convertFileToSequence~~~g_disk2nim~~~proc~~~ls:136~~~cs:5~~~ce:25
convertMultFilesToSeq~~~g_disk2nim~~~proc~~~ls:159~~~cs:5~~~ce:25
other_declaration~~~g_disk2nim~~~when isMainModul~~~ls:183
other_declaration~~~g_templates~~~import std/[time~~~ls:1
other_declaration~~~g_templates~~~var versionfl: f~~~ls:3
withFile~~~g_templates~~~template~~~ls:6~~~cs:9~~~ce:16
withFileAdvanced~~~g_templates~~~template~~~ls:18~~~cs:9~~~ce:24
doWork~~~g_templates~~~proc~~~ls:45~~~cs:5~~~ce:10
timeStuff~~~g_templates~~~template~~~ls:51~~~cs:9~~~ce:17
timeThings~~~g_templates~~~template~~~ls:57~~~cs:9~~~ce:18
timeNeatly~~~g_templates~~~template~~~ls:65~~~cs:9~~~ce:18
timeCop~~~g_templates~~~template~~~ls:71~~~cs:9~~~ce:15
other_declaration~~~g_templates~~~when isMainModul~~~ls:81
28 changes: 28 additions & 0 deletions mostfiles/projects/codetwig/codetwi_phase2_dec_list.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
addSourceFilesToProject~~~ctwig~~~proc~~~ls:35~~~cs:5~~~ce:27~~~le:113
extractFileSectionToSequence~~~ctwig~~~proc~~~ls:114~~~cs:5~~~ce:32~~~le:136
getSliceFromAnchor~~~ctwig~~~proc~~~ls:137~~~cs:5~~~ce:22~~~le:210
countLinesOfFile~~~ctwig~~~proc~~~ls:211~~~cs:5~~~ce:20~~~le:223
createDeclarationList~~~ctwig~~~proc~~~ls:224~~~cs:5~~~ce:25~~~le:503
createCodeViewFile~~~ctwig~~~proc~~~ls:504~~~cs:5~~~ce:22~~~le:620
getSeqFromFileLines~~~ctwig~~~proc~~~ls:621~~~cs:5~~~ce:23~~~le:679
getSeqFromLinesSpecial~~~ctwig~~~proc~~~ls:680~~~cs:5~~~ce:26~~~le:726
writeFamily~~~ctwig~~~proc~~~ls:727~~~cs:5~~~ce:15~~~le:801
showDeclarationBranch~~~ctwig~~~proc~~~ls:802~~~cs:5~~~ce:25~~~le:901
echoHelpInfo~~~ctwig~~~proc~~~ls:902~~~cs:5~~~ce:16~~~le:947
createAllViewFiles~~~ctwig~~~proc~~~ls:948~~~cs:5~~~ce:22~~~le:954
generate_all~~~ctwig~~~proc~~~ls:955~~~cs:5~~~ce:16~~~le:962
processCommandLine~~~ctwig~~~proc~~~ls:963~~~cs:5~~~ce:22~~~le:1065
log~~~g_disk2nim~~~template~~~ls:11~~~cs:9~~~ce:11~~~le:17
writeFilePatternToSeq~~~g_disk2nim~~~proc~~~ls:18~~~cs:5~~~ce:25~~~le:39
getPatternLocation~~~g_disk2nim~~~proc~~~ls:40~~~cs:5~~~ce:22~~~le:65
writeFilePatternToSeq2~~~g_disk2nim~~~proc~~~ls:66~~~cs:5~~~ce:26~~~le:115
addShowValuesToSeq~~~g_disk2nim~~~proc~~~ls:116~~~cs:5~~~ce:22~~~le:135
convertFileToSequence~~~g_disk2nim~~~proc~~~ls:136~~~cs:5~~~ce:25~~~le:158
convertMultFilesToSeq~~~g_disk2nim~~~proc~~~ls:159~~~cs:5~~~ce:25~~~le:182
withFile~~~g_templates~~~template~~~ls:6~~~cs:9~~~ce:16~~~le:17
withFileAdvanced~~~g_templates~~~template~~~ls:18~~~cs:9~~~ce:24~~~le:44
doWork~~~g_templates~~~proc~~~ls:45~~~cs:5~~~ce:10~~~le:50
timeStuff~~~g_templates~~~template~~~ls:51~~~cs:9~~~ce:17~~~le:56
timeThings~~~g_templates~~~template~~~ls:57~~~cs:9~~~ce:18~~~le:64
timeNeatly~~~g_templates~~~template~~~ls:65~~~cs:9~~~ce:18~~~le:70
timeCop~~~g_templates~~~template~~~ls:71~~~cs:9~~~ce:15~~~le:80
28 changes: 28 additions & 0 deletions mostfiles/projects/codetwig/codetwi_phase3_dec_list.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
addSourceFilesToProject~~~ctwig~~~proc~~~ls:35~~~cs:5~~~ce:27~~~le:113===writeFilePatternToSeq~~~g_disk2nim~~~proc~~~80===writeFilePatternToSeq2~~~g_disk2nim~~~proc~~~80
extractFileSectionToSequence~~~ctwig~~~proc~~~ls:114~~~cs:5~~~ce:32~~~le:136===withFile~~~g_templates~~~template~~~125===withFileAdvanced~~~g_templates~~~template~~~125
getSliceFromAnchor~~~ctwig~~~proc~~~ls:137~~~cs:5~~~ce:22~~~le:210
countLinesOfFile~~~ctwig~~~proc~~~ls:211~~~cs:5~~~ce:20~~~le:223
createDeclarationList~~~ctwig~~~proc~~~ls:224~~~cs:5~~~ce:25~~~le:503===extractFileSectionToSequence~~~ctwig~~~proc~~~281===getSliceFromAnchor~~~ctwig~~~proc~~~333===countLinesOfFile~~~ctwig~~~proc~~~390
createCodeViewFile~~~ctwig~~~proc~~~ls:504~~~cs:5~~~ce:22~~~le:620===extractFileSectionToSequence~~~ctwig~~~proc~~~528
getSeqFromFileLines~~~ctwig~~~proc~~~ls:621~~~cs:5~~~ce:23~~~le:679
getSeqFromLinesSpecial~~~ctwig~~~proc~~~ls:680~~~cs:5~~~ce:26~~~le:726
writeFamily~~~ctwig~~~proc~~~ls:727~~~cs:5~~~ce:15~~~le:801===getSeqFromFileLines~~~ctwig~~~proc~~~756===getSeqFromLinesSpecial~~~ctwig~~~proc~~~771===writeFamily~~~ctwig~~~proc~~~767
showDeclarationBranch~~~ctwig~~~proc~~~ls:802~~~cs:5~~~ce:25~~~le:901===extractFileSectionToSequence~~~ctwig~~~proc~~~826===getSeqFromFileLines~~~ctwig~~~proc~~~843===writeFamily~~~ctwig~~~proc~~~866
echoHelpInfo~~~ctwig~~~proc~~~ls:902~~~cs:5~~~ce:16~~~le:947
createAllViewFiles~~~ctwig~~~proc~~~ls:948~~~cs:5~~~ce:22~~~le:954===createCodeViewFile~~~ctwig~~~proc~~~950
generate_all~~~ctwig~~~proc~~~ls:955~~~cs:5~~~ce:16~~~le:962===createDeclarationList~~~ctwig~~~proc~~~957===createAllViewFiles~~~ctwig~~~proc~~~958
processCommandLine~~~ctwig~~~proc~~~ls:963~~~cs:5~~~ce:22~~~le:1065===addSourceFilesToProject~~~ctwig~~~proc~~~1027===createDeclarationList~~~ctwig~~~proc~~~1029===showDeclarationBranch~~~ctwig~~~proc~~~1035===echoHelpInfo~~~ctwig~~~proc~~~1037===createAllViewFiles~~~ctwig~~~proc~~~1031===generate_all~~~ctwig~~~proc~~~1033
log~~~g_disk2nim~~~template~~~ls:11~~~cs:9~~~ce:11~~~le:17
writeFilePatternToSeq~~~g_disk2nim~~~proc~~~ls:18~~~cs:5~~~ce:25~~~le:39
getPatternLocation~~~g_disk2nim~~~proc~~~ls:40~~~cs:5~~~ce:22~~~le:65
writeFilePatternToSeq2~~~g_disk2nim~~~proc~~~ls:66~~~cs:5~~~ce:26~~~le:115===getPatternLocation~~~g_disk2nim~~~proc~~~81
addShowValuesToSeq~~~g_disk2nim~~~proc~~~ls:116~~~cs:5~~~ce:22~~~le:135
convertFileToSequence~~~g_disk2nim~~~proc~~~ls:136~~~cs:5~~~ce:25~~~le:158===withFile~~~g_templates~~~template~~~144
convertMultFilesToSeq~~~g_disk2nim~~~proc~~~ls:159~~~cs:5~~~ce:25~~~le:182===withFile~~~g_templates~~~template~~~169
withFile~~~g_templates~~~template~~~ls:6~~~cs:9~~~ce:16~~~le:17
withFileAdvanced~~~g_templates~~~template~~~ls:18~~~cs:9~~~ce:24~~~le:44
doWork~~~g_templates~~~proc~~~ls:45~~~cs:5~~~ce:10~~~le:50
timeStuff~~~g_templates~~~template~~~ls:51~~~cs:9~~~ce:17~~~le:56
timeThings~~~g_templates~~~template~~~ls:57~~~cs:9~~~ce:18~~~le:64
timeNeatly~~~g_templates~~~template~~~ls:65~~~cs:9~~~ce:18~~~le:70
timeCop~~~g_templates~~~template~~~ls:71~~~cs:9~~~ce:15~~~le:80
2 changes: 2 additions & 0 deletions mostfiles/projects/project_template_to_copy.pro
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ the/path/to/your/project-source-files

SOURCE_FILES
>----------------------------------<


0 comments on commit c9f0a2f

Please sign in to comment.