diff --git a/.gitignore b/.gitignore index b959e80..7556fab 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ *.2mg *.po # merlin assembly listings -*_output.txt \ No newline at end of file +*_output.txt +*.exe \ No newline at end of file diff --git a/README.md b/README.md index e0a6a94..a001067 100644 --- a/README.md +++ b/README.md @@ -27,10 +27,13 @@ Appy abstracts the tools away from a script mindset, and into a project mindset. ## The project file -Currently it uses an `appy.yaml` file in the current project directory. The format is as follows: +Appy uses an `appy.yaml` file in the current project directory. The basic format is as follows: ``` assemble: [main.s, grafix.s, snd.s, a.s, b.s] # <--- list of files to assemble with Merlin -indent: [c.s] # <--- additional files to indent when running `appy fmt` +assembleflags: "-V" # <--- optional flags to Merlin, including macro directory +indent: [c.s] # <--- optional additional files to indent when running `appy fmt` +formatflags: "mc:10 oc:14 cc:30 ms:1 bs:2" # <--- optional flags to indent + disks: # <--- define disks, can be more than one, handy for 140K + 800K - name: mydiskimage # <---- each disk has a name (ProDOS volume name) file: mydiskimage800.2mg # <---- each disk has a filename for the image it creates @@ -78,6 +81,34 @@ $ appy fmt # format/indent your assembly file in appy.yaml # you can also pass in filename(s) to format ``` +### About the built-in code formatter + +Appy uses the [MerlinGo](https://github.com/digarok/merlingo) formatter to indent source code. You can override the default indentation with the various options documented here. + +- `mc`: mnemonic column, where instructions start +- `oc`: opcode column +- `cc`: comment column +- `ms`: min space, the minimum amount of space it will allow between two columns + +You can define these in your `appy.yaml` project file like so: +``` +formatflags: "mc:10 oc:14 cc:30 ms:1" +``` + +You can also set it in files directly by adding it as a comment marked `ed:` on any line of the file like: +``` +* ed: mc=40 oc=26 cc=48 ms=5 <- indentation modeline +``` + OR +``` + org $2000 + ; ed: mc=40 oc=26 cc=48 ms=5 <- indentation modeline + lda ... +``` +Again either comment style works on any line of the file, but don't add more than one modeline per file. + +Also, if you set format options at the project AND file level, then Appy will use the project defaults except when a file specifies its own settings, then it will respect the file settings instead. + ### Version Notes This is an early experimental version not intended for public use. diff --git a/appy.yaml b/appy.yaml index f3f8f6c..51f16ee 100644 --- a/appy.yaml +++ b/appy.yaml @@ -1,5 +1,6 @@ assemble: [testsrc/sp.s, testsrc/pc.s, testsrc/fmt.s] assembleflags: "-V" +formatflags: "mc:10 oc:14 cc:30 ms:1 bs:2" indent: [testsrc/fmt2.s] disks: - name: mydiskimage diff --git a/core/formatter.go b/core/formatter.go index bc18ee9..93af187 100644 --- a/core/formatter.go +++ b/core/formatter.go @@ -8,6 +8,10 @@ import ( ) func Format(args []string) { + // merlingo.Status() + if project.AppyProj.FormatFlags != "" { + merlingo.ParseModeline(project.AppyProj.FormatFlags) + } if len(args) == 0 { // format all assembly files in appy.yaml for _, filename := range project.AppyProj.Assemble { @@ -26,4 +30,5 @@ func Format(args []string) { merlingo.FmtFile(filename) } } + // merlingo.Status() } diff --git a/core/project/project.go b/core/project/project.go index fab1ebf..2921fb6 100644 --- a/core/project/project.go +++ b/core/project/project.go @@ -15,6 +15,7 @@ type Project struct { Assemble []string Indent []string AssembleFlags string + FormatFlags string } type Disk struct { diff --git a/go.mod b/go.mod index cd4fe97..a642e57 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/digarok/appy go 1.16 require ( - github.com/digarok/merlingo v1.0.3 + github.com/digarok/merlingo v1.0.4 github.com/fatih/color v1.13.0 github.com/mitchellh/go-homedir v1.1.0 github.com/spf13/cobra v1.1.3 diff --git a/go.sum b/go.sum index 93f5dbd..d17eb0f 100644 --- a/go.sum +++ b/go.sum @@ -39,6 +39,8 @@ github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZm github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= github.com/digarok/merlingo v1.0.3 h1:W0jtn8PZQsBlkpvfODFO38GSFx91uV4LXDhN1dkK62A= github.com/digarok/merlingo v1.0.3/go.mod h1:rdReR6enl/63dfkssdM4xwg0gXw3j4QprK9e+e8mX9U= +github.com/digarok/merlingo v1.0.4 h1:9OMF44OFas04cKGh9qql56IvOGrWjjbgri+n8LqLd88= +github.com/digarok/merlingo v1.0.4/go.mod h1:rdReR6enl/63dfkssdM4xwg0gXw3j4QprK9e+e8mX9U= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w= github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= diff --git a/testsrc/fmt2.s b/testsrc/fmt2.s index 70a02af..f7d68cb 100644 --- a/testsrc/fmt2.s +++ b/testsrc/fmt2.s @@ -25,3 +25,4 @@ ReallyThisisaLoooooongLabelwith stal $e12000,y ; look at this long line * TABS.... * $D5 $0008 sequence [Application Specific] + ; ed: mc=40 oc=26 cc=48 ms=5 bs=2 <- indentation modeline