home *** CD-ROM | disk | FTP | other *** search
- #include "marislib.ch"
- #include "inkey.ch"
- #include "rn.ch"
-
- FUNCTION BrowseNewsgroup(nTop, nLeft, nBottom, nRight, a)
-
- LOCAL b:= TBrowseNew(nTop, nLeft, nBottom, nRight)
- LOCAL i:= 1
- LOCAL nKey
- LOCAL lSavReadexit := readexit(.t.)
- LOCAL bUdf
- LOCAl bColumn
-
- KeyBar({" = Select", "─┘ = Read", "Space or Tab = Read new", "Esc = Exit", "F1 = Help"}, CLR_HDR)
- b:colorspec := "bg+/b, n/bg, bg+/b, bg+/b, bg+/b, gr+/b, gr+/bg"
-
- bColumn := TBColumnNew("", {|| padr(" " + padr(a[i,1],60) + " " + if (a[i,4] > 0, "(" + str(a[i,4],4) + ")", space(6)) + if(a[i,3] > 0, str(a[i,3],4), space(4)), 80) })
- b:addColumn( bColumn )
- bColumn:colorBlock := {|x| if( a[i,4] > 0, { 6, 7}, {1, 2}) }
-
- bUdf := {|a, b, nKey, i|UdfBrowseNewsgroup(a, b, nKey, i)}
-
- b:goTopBlock := { ||i := 1 }
- b:goBottomBlock := { || i := len(a) }
- b:skipBlock := {|n, si| si := i, ;
- i := if(n > 0, ;
- min(len(a), i + n), ;
- max (1, i+n)), ;
- i -si }
- b:freeze := 1
-
-
- do while nKey != K_ESC
- while ! b:stabilize()
- enddo
-
- IF b:hitTop .OR. b:hitBottom
- sound(3500, 10, 80, 25)
- ENDIF
-
- // Make sure that the current record is showing
- // up-to-date data in case we are on a network.
- b:refreshCurrent()
- ForceStable(b)
-
- nKey := inkey(0)
- b := eval(bUdf, a, b, nKey, i)
- enddo
- readexit (lSavReadexit)
- RETURN (a)
-
-
-
- STATIC FUNCTION UDFBrowseNewsgroup (a, ; // array
- b, ; // TBrowse object
- nKey,; // key pressed
- i ; // current position within array
- )
- LOCAl aMsg
- LOCAL n
- LOCAL nSavPos
-
- do case
- case chr(nKey) == 'p'
- NwsPost(a[i,1])
-
- case nKey == asc("P")
- pmail()
-
- case chr(nKey) == '!'
- shell()
-
- case nKey == K_DOWN
- b:down()
-
- case nKey == K_PGDN
- b:pageDown()
-
- case nKey == K_PGUP
- b:pageUp()
-
- case nKey == K_CTRL_PGDN
- b:goBottom()
-
- case nKey == K_CTRL_PGUP
- b:goTop()
-
- case nKey == K_HOME
- b:gotop()
-
- case nKey == K_END
- b:gobottom()
-
- case nKey == K_CTRL_LEFT
- b:left()
-
- case nKey == K_CTRL_RIGHT
- b:right()
-
- case nKey == K_UP
- b:up()
-
- case nKey == K_SPACE .or. nKey == K_TAB
- nSavPos := i
- while i <= len(a)
- if a[i, 4] > 0
- aMsg := ReadNewsgroup(a[i,1], READ_NG_NORMAL)
- a[i, 4] := 0
- for n := 1 to len(aMsg)
- if IsNew(aMsg[n, 4])
- a[i, 4] ++
- endif
- next
- EXIT
- endif
- ++i
- enddo
-
- if i # len(a)
- for n := nSavPos to i
- b:down()
- next
- endif
-
- b:refreshall()
- forcestable( b )
-
- case nKey == K_RETURN
- aMsg := ReadNewsgroup(a[i,1], READ_NG_NORMAL)
- a[i, 4] := 0
- for n := 1 to len(aMsg)
- if IsNew(aMsg[n, 4])
- a[i, 4] ++
- endif
- next
-
- case chr(nKey) == "c" // catchup
- if a[i,4] > 0
- ReadNewsgroup(a[i,1], READ_NG_CATCHUP)
- a[i,4] := 0
- b:refreshcurrent()
- ForceStable(b)
- endif
- endcase
-
- RETURN (b)
-
-
-