quran-go

Read Qur'an right in the terminal.
git clone http://git.hanabi.in/repos/quran-go.git
Log | Files | Refs | README | LICENSE

verses.go (1033B)


      1 package display
      2 
      3 import (
      4 	"fmt"
      5 
      6 	d "git.hanabi.in/gitbox/quran-go/src/display/decorate"
      7 	f "git.hanabi.in/gitbox/quran-go/src/fetch"
      8 	p "git.hanabi.in/gitbox/quran-go/src/print"
      9 	t "git.hanabi.in/gitbox/quran-go/src/types"
     10 	u "git.hanabi.in/gitbox/quran-go/src/utils"
     11 )
     12 
     13 // Display verses from verse1 to verse2.
     14 func Verses(chapter t.Chap, verse1, verse2 t.Verse, author string, translationID t.Trans, delay t.Delay, shouldDecorate bool) {
     15 
     16 	if shouldDecorate {
     17 		d.ChapterHead(chapter)
     18 	}
     19 
     20 	for verse := verse1; verse <= verse2; verse++ {
     21 		printVerse(translationID, chapter, verse, delay, shouldDecorate)
     22 	}
     23 
     24 	if shouldDecorate {
     25 		d.End(author, chapter, verse1, verse2)
     26 	}
     27 
     28 }
     29 
     30 // Print a single verse.
     31 func printVerse(transID t.Trans, chapID t.Chap, verse t.Verse, delay t.Delay, shouldDecorate bool) {
     32 	aayat, err := f.Aayat(transID, chapID, verse, delay)
     33 	if err != nil {
     34 		p.Err(err)
     35 	}
     36 
     37 	formattedAayat := u.FormatAayat(aayat)
     38 
     39 	if shouldDecorate {
     40 		fmt.Printf("(%d:%d) ", chapID, verse)
     41 	}
     42 
     43 	fmt.Println(formattedAayat)
     44 }