Skip to content

Commit

Permalink
Clean up the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
josephspurrier committed Jan 13, 2019
1 parent ce47ccd commit de32044
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
[![Coverage Status](https://coveralls.io/repos/github/josephspurrier/texman/badge.svg?branch=master&timestamp=20180923-01)](https://coveralls.io/github/josephspurrier/texman?branch=master)
[![GoDoc](https://godoc.org/github.com/josephspurrier/texman?status.svg)](https://godoc.org/github.com/josephspurrier/texman)

Simple package for making character and line changes to text files in Go. This is designed to be an example respository in Go.
Simple package for making character and line changes to text files in Go. This is designed to be an example respository in Go. Please view the GoDoc for more information.
27 changes: 14 additions & 13 deletions texman.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Package texman provides a few simple functions to make characters and line
// changes to a text file.
// changes to a text file. The row and column inputs should be 1 or greater.
// A row of 1 and a column of 1 is the first available location.
package texman

import (
Expand Down Expand Up @@ -27,7 +28,7 @@ func NewFile(filename string) *TM {
}
}

// Load will read a file into memory
// Load reads a file into memory.
func (s *TM) Load() error {
s.content = make([][]rune, 0)

Expand All @@ -54,7 +55,7 @@ func (s *TM) Load() error {
return nil
}

// String will return a string representation of the text.
// String returns a string representation of the text.
func (s *TM) String() string {
out := ""
for r := 0; r < len(s.content); r++ {
Expand All @@ -70,7 +71,7 @@ func (s *TM) String() string {
return out
}

// Byte will return a byte array representation of the text.
// Byte returns a byte array representation of the text.
func (s *TM) Byte() []byte {
return []byte(s.String())
}
Expand All @@ -85,14 +86,14 @@ func validate(row int, col int) error {
return nil
}

// Overwrite will overwrite content at a specific location.
// Overwrite replaces content at a specific location.
func (s *TM) Overwrite(row int, col int, content string) error {
err := validate(row, col)
if err != nil {
return err
}

// Fix the offset since computers start at 0.
// Fix the offset since arrays start at 0.
row--
col--

Expand All @@ -116,14 +117,14 @@ func (s *TM) Overwrite(row int, col int, content string) error {
return nil
}

// Insert will insert content at a specific location.
// Insert adds content at a specific location.
func (s *TM) Insert(row int, col int, content string) error {
err := validate(row, col)
if err != nil {
return err
}

// Fix the offset since computers start at 0.
// Fix the offset since arrays start at 0.
row--
col--

Expand Down Expand Up @@ -158,19 +159,19 @@ func (s *TM) Insert(row int, col int, content string) error {
return nil
}

// InsertLine will insert a new line.
// InsertLine inserts a new line at a specific location.
func (s *TM) InsertLine(row int, col int) error {
return s.Insert(row, col, s.LineEnding)
}

// Delete a character at the specified location.
// Delete removes a character at a specified location.
func (s *TM) Delete(row int, col int) error {
err := validate(row, col)
if err != nil {
return err
}

// Fix the offset since computers start at 0.
// Fix the offset since arrays start at 0.
row--
col--

Expand All @@ -191,14 +192,14 @@ func (s *TM) Delete(row int, col int) error {
return nil
}

// DeleteLine will delete a line.
// DeleteLine deletes a line at a specific location.
func (s *TM) DeleteLine(row int) error {
err := validate(row, 1)
if err != nil {
return err
}

// Fix the offset since computers start at 0.
// Fix the offset since arrays start at 0.
row--

if row >= len(s.content) {
Expand Down

0 comments on commit de32044

Please sign in to comment.