Buchempfehlung
Visual Basic 6 Kochbuch
Visual Basic 6 Kochbuch
Viele praktische Tipps zum Programmieren mit Visual Basic 6, die sich oft auch auf FB übertragen lassen. [Mehr Infos...]
FreeBASIC-Chat
Es sind Benutzer im FreeBASIC-Chat online.
(Stand:  )
FreeBASIC bei Twitter
Twitter FreeBASIC-Nachrichten jetzt auch über Twitter erhalten. Follow us!

fb:porticula NoPaste

Info
Info / Hilfe
Liste
Übersicht / Liste
Neu
Datei hochladen
Suche
Quellcode suchen
Download
Dateidownload

MuhEdit 0.6.7.2

Uploader:MitgliedThe_Muh
Datum/Zeit:07.07.2008 23:11:20

''''''''''''''''''''''''/
'MuhEdit, programming and Idea by The_Muh
'Thanks at: MisterD and ThePuppetMaster
'Lizence:
'Creative Commons:
'by-nc-sa
''''''''''''''''''''''''/
'version 0.6.7.2
'subs und funktionen (declare):
declare sub speichern()
declare sub laden()
declare sub standartText(seite as string)
declare function directory() as string
declare function file() as string
declare sub curs(zeile as integer, spalte as integer, aspalte as integer, azeile as integer)
'Variablen:
dim shared as integer hoehe, breite
breite = 50
hoehe = 50
dim d as string
dim as string Li, Re
dim ascL as integer
dim ascR as integer
dim shared as string tZeile(1 to 50)
dim as string seite
dim as integer aspalte, azeile
dim shared as integer zeile=3, spalte=1
dim as integer mzeile, mspalte, buttons
dim i as integer
dim L as integer
dim dirs as string

'subs und funktionen:
function directory() as string
    dim dirs as string
    cls
    locate 1, 1 : PRINT "MuhEdit Filechoser"
    locate 2, 1 : Print String(50, asc("_"))
    DIM AS STRING dirname(0 to 50)
    dim as integer i = 1
    dim as integer c
    print "0) \.."

    dirname(1) = DIR("*", &H10) ' das erste verzeichnis
    do                          ' alle anderen =)
        print i & ") \" & dirname(i)
        i +=1
        dirname(i) = DIR("")
    LOOP WHILE LEN(dirname(i)) ' solange noch ein nicht gelistetes Verzeichnis existiert
    Locate (hoehe - 2), 1 : Print String(50, asc("_"))

    if len(dirname(1)) >= 1 then
        do
            locate (hoehe - 1), 1 : Print String(50, asc(" "))
            Locate (hoehe - 1), 1 : input "Number: ",c
        if len(dirname(c)) >=1 then
            Locate (hoehe - 1), 1 : Print "Accepted"
            dirs = dirname(c)
            exit do
        elseif c = 0 then
            CHDIR ".."
            exit do
        else
            Locate (hoehe - 1), 1 : Print "False"
        end if
        loop
    else
         locate (hoehe - 1), 1 : Print String(50, asc(" "))
         locate (hoehe - 1), 1 : Print "No Directorys"
    end if
    getkey
    return dirs
end function

function file() as string
    dim files as string
    dim filename(1 to 50) as string
    dim as integer i = 1
    dim as integer c

    filename(1) = DIR("*.txt",0) ' das erste verzeichnis
    do                          ' alle anderen =)
        print i & ") \" & filename(i)
        i +=1
        filename(i) = DIR("")
    LOOP WHILE LEN(filename(i)) ' solange noch ein nicht gelistetes Verzeichnis existiert
    Locate (hoehe - 2), 1 : Print String(50, asc("_"))

    if len(filename(1)) >= 1 then
        do
            locate (hoehe - 1), 1 : Print String(50, asc(" "))
            Locate (hoehe - 1), 1 : input "Number: ",c
        if len(filename(c)) >=1 then
            Locate (hoehe - 1), 1 : Print "Accepted"
            files = filename(c)
            exit do
        else
            Locate (hoehe - 1), 1 : Print "False"
        end if
        loop
    else
         locate (hoehe - 1), 1 : Print String(50, asc(" "))
         locate (hoehe - 1), 1 : Print "No files"
    end if
    getkey
    return files
end function

sub speichern()
    dim files as string
    dim seite as string
    dim x as integer
    cls
    locate 1, 1           : PRINT "MuhEdit Saver"
    locate 2, 1           : Print String(50, asc("_"))
    Locate (hoehe - 2), 1 : Print String(50, asc("_"))
    Locate (hoehe - 1), 1 : input "Filename (Without .txt): ",files
    seite = files + ".txt"

    OPEN seite FOR OUTPUT AS #1
    For x = 1 to UBound(TZeile)
        PRINT #1, tzeile(x)
    next
    CLOSE #1
    Locate (hoehe - 1), 1 : Print "Accepted                                          "
    getkey
end sub

sub laden()
    dim seite as string
    dim as integer i
    dim as integer X
    seite = file()
    For X = 1 to 50
        tzeile(X) = ""
    Next

    OPEN seite FOR INPUT AS #1
    while not EOF(1)
        i += 1
        if i > 50 then exit while
        line INPUT #1, tzeile(i)
    wend
    CLOSE #1
    cls
end sub

sub standartText(seite as string)
    locate 1, 1 : PRINT "MuhEdit / Change Directory = F4 / Save = F3 / Quit = ESC  "
    locate 2, 1 : Print String(50, asc("_"))
    Locate (hoehe - 2),1 : Print String(50, asc("_"))
    Locate (hoehe - 1),1 : Print "Page: "& seite &" | Open another page = F2    "
end sub

sub curs(zeile as integer, spalte as integer, aspalte as integer, azeile as integer)
    if azeile < zeile then
        locate azeile, aspalte
        print " "
    end if
    if azeile > zeile then
        locate azeile, aspalte
        print " "
    end if
        locate zeile, spalte
        print "_"
end sub


'hauptprogramm:
dirs = curdir
screenres 400,400
COLOR 0, 15
CLS
standartText(seite)
DO
    cls
    L = len(tzeile(zeile))
    if L < spalte then
        for i = L to spalte - L -1
            tzeile(zeile) += chr(32)
        next i
    end if
    standartText(seite)
    for sh as integer = 3 to 47         'text anzeigen...
        locate sh, 1
        print tzeile(sh)
    next sh
    curs(zeile,spalte,aspalte,azeile)
    aspalte = spalte
    azeile = zeile

    'auf eingabe warten
    do:sleep 1
    getmouse mspalte, mzeile,,buttons
    mzeile = mzeile / 8
    mspalte = mspalte / 8

    if buttons >= 1 then
        if mzeile < (hoehe - 3) and mzeile > 3 then
            zeile = mzeile
        end if
            spalte = mspalte
    end if
    d=inkey:loop until d<>"" or (buttons >= 1)        'wartet auf Usereingabe

    locate zeile ,spalte
    Li = mid(d, 1,1)
    Re = mid(d, 2.1)
    ascL = asc(Li)
    ascR = asc(Re)

    SELECT CASE ascR
    case 72:                      'oben
        if zeile > 3 then
            zeile -= 1
        else
            zeile = (hoehe - 3)
        end if
    case 80:                         'unten
        if zeile < (hoehe - 3) then
            zeile += 1
        else
            zeile = 3
        end if
    case 75:                         'links
        if spalte>1 then                        'nicht am zeilenanfang
            print chr(32)
            spalte-=1
        else                                    'am zeilenanfang
            if zeile > 3 then
                zeile -= 1
                spalte = 50
            else
                zeile = (hoehe - 3)
                spalte = 50
            end if
        end if
    case 77:                           'rechts
        if spalte <> 50 then
            print chr(32)
            spalte += 1
        elseif spalte = 50 and zeile < (hoehe - 3) then
            zeile += 1
            spalte = 1
        else
            zeile = 3
            spalte = 1
        end if

    case 107:                        'das X oben
        exit do
    case 62:                            'F4 (verzeichnis wechseln)
        dirs = directory()
        chdir (dirs)
        standartText(seite)
    case 61:                          'seite speichern(F3)
        speichern()
        standartText(seite)
        locate 3, 1
    case 60:                          'Laden (F2)
        laden()
        standartText(seite)
        locate 3, 1
    case 63:
        CLS
        zeile = 3 : spalte = 1
    end select

    if ascL <> 255 then
    select case ascL
        case 8:                               'backspace
        if spalte>1 then                        'nicht am zeilenanfang
            spalte-=1
            locate zeile,spalte
            print chr(32)&chr(32)
            tzeile(zeile)=left(tzeile(zeile),len(tzeile(zeile))-1)
        else                                    'am zeilenanfang
            if zeile > 3 then
                zeile -= 1
                spalte = 50
                locate zeile, spalte
                print " "
            else
                beep
            end if
        end if
    case 13:                              'enter
        if zeile > 23 then
            zeile = 3
            spalte = 1
        else
            spalte = 1
            zeile += 1
        end if
    case 27:                              'escape
        exit do
    case else:
    Print d;
    spalte+=1
        if spalte >= 50 then
            spalte = 1
            zeile+=1
            if zeile>(hoehe - 3) then zeile=3
        end if
    if L > spalte then
        MID(tzeile(zeile), spalte - 1, 1) = d
    else
    tzeile(zeile) = tzeile(zeile) + d
    end if
    end select
    end if
loop

cls
locate 1, 1
PRINT "TextEditor by The_Muh | Press any key to quit   "
locate 2, 1 : Print String(50, asc("_"))

Locate (hoehe - 2),1 : Print String(50, asc("_"))
Locate (hoehe - 1),1
Print "Programming and Idea:                   The_Muh"
getkey
end
'---------------------------------------------------------------
'todo (bis 0.7.5):
'mehr als 50 zeilen (0%)
'mehr als 50 spalten (0%)
'neues speicher-system (75%))
'   - Den Kompletten array speichern (auch wenn größer als 50)
'
'todo (bis 0.8)
'Funktionierende Umlaute und sonderzeichen unter Linux
'---------------------------------------------------------------