Buchempfehlung
MySQL kurz & gut
MySQL kurz & gut
Das preiswerte Taschen- buch stellt MySQL-rele- vante Inhalte systematisch und knapp dar, sodass es sich optimal zum Nach- schlagen beim Pro- grammieren eignet. [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.7.2

Uploader:MitgliedThe_Muh
Datum/Zeit:12.07.2008 03:22:45

''''''''''''''''''''''''/
'MuhEdit, programming and Idea by The_Muh
'Thanks to: MisterD and ThePuppetMaster
'licence:
'Creative Commons:
'by-nc-sa
''''''''''''''''''''''''/
'version 0.7.2
'subs und funktionen (declare):
declare sub laden()
declare function speichern() as string
declare function directory() as string
declare function file() as string
declare sub text(ByVal Maeh As Integer)
declare sub anzeige(anzeigetext() as string, XY as integer, modus as integer)
declare function eingabe(ByVal frage As String ,vorgabe As String, X as integer,Y as integer) as string
'Variablen:
dim shared as integer hoehe, breite
dim d as string
dim as string Li, Re
dim as integer ascL, ascR
dim shared as string tZeile()
dim shared as string seite
dim shared as integer zeile=3, spalte=1
dim as integer mzeile, mspalte, buttons
dim i as integer
dim L as integer
Dim einf as integer
dim dirs as string
dim rest as string
dim shared a as integer
dim b as integer

breite = 50
hoehe = 50
einf = 1
A = 0
REDIM tzeile(47) AS STRING

'subs und funktionen:
sub anzeige(anzeigetext() as string, XY as integer, modus as integer)
    select case modus
    case 1: 'in der höhe
        cls
        text(1)
        if XY >= 0 then

            for sh as integer = 3 to 47     'text anzeigen...
                if SH + XY <= ubound(anzeigetext) then
                    locate sh, 1
                    print anzeigetext(sh+xy)
                else
                    exit for
                end if
            next sh
        else
            for sh as integer = 3 to 47
                locate sh, 1
                print anzeigetext(sh)
            next sh
        end if
    'breite kommt noch
    end select
end sub

function eingabe(ByVal frage As String ,vorgabe As String, X as integer,Y as integer) as string
    dim zeichen as string
    dim zeichenkette as string
    dim L as integer
    dim Li as string
    dim Re as string
    dim ascR as integer
    dim ascL as integer
    dim einf as integer
    dim spalte as integer
    dim rest as string
    einf = 1
    zeichenkette = vorgabe
    locate x, y
       print frage & " " & Zeichenkette
       spalte = len(zeichenkette)
       y = len(frage)
    do
        cls
        text(6)
        locate x : print frage
        locate x, len(frage) + 1: print Zeichenkette
        DRAW STRING ((y + spalte -1)*8 , (x-1)*8), "_",  'Cursor anzeigen
        do : sleep 1 : zeichen = inkey : loop while zeichen = ""

        Li = mid(zeichen, 1,1)
        Re = mid(zeichen, 2.1)
        ascL = asc(Li)
        ascR = asc(Re)

        L = len(zeichenkette)
        select case ascR
        case 82                                'testen ob "einf" gedrückt wurde
            if einf = 1 then                             'der umschalter
                einf = 0
            else
                einf = 1
            end if
        case 75:                         'links
            if spalte > 1 then spalte -= 1
        case 77:                           'rechts
            if spalte < L then spalte += 1
        end select

        if ascL <> 255 then
        select case ascL
        case 8                                            'backspace
            if L >= spalte then
                rest = right(zeichenkette, (L - spalte))
                MID(zeichenkette, spalte, len(rest)) = rest
                zeichenkette=left(zeichenkette,len(zeichenkette)-1)
            else
                zeichenkette=left(zeichenkette,len(zeichenkette)-1)
            end if

            if spalte <> 1 then spalte -= 1
        case 13                                        'enter
            return zeichenkette
            locate 3,1
            exit function
        case 27
            return vorgabe
            locate 3,1
            exit function
        case 127                                        'entf
            if L >= spalte then
                rest = right(zeichenkette, (L - spalte))
                MID(zeichenkette, spalte, len(rest)) = rest
                zeichenkette=left(zeichenkette,len(zeichenkette)-1)
            end if
        case else
            if L >= spalte then
                if einf = 0 then
                    MID(zeichenkette, spalte, 1) = zeichen
                else
                    zeichenkette = left(zeichenkette, spalte -1) + zeichen + right(zeichenkette, (L - spalte +1) )
                end if
            else
                zeichenkette = zeichenkette + zeichen
            end if
            spalte += 1
        end select
        end if
    loop until zeichen = chr(13)
end function

function directory() as string
    dim dirs as string
    cls
    locate 1, 1 : PRINT "MuhEdit Directory"
    locate 2, 1 : Print String(50, asc("_"))
    DIM AS STRING dirname()
    dim as integer i = 1
    dim as integer c
    Locate 4,1
    print "0) \.."

    redim dirname(1)
    dirname(1) = DIR("*", &H10) ' das erste verzeichnis
    do                          ' alle anderen =)
        if dirname(i) <> "."  then
            print i & ") \" & dirname(i)
        end if
        i +=1
        redim preserve dirname(i)
        dirname(i) = DIR("",&H10)
    LOOP WHILE LEN(dirname(i)) ' solange noch ein nicht gelistetes Verzeichnis existiert
    text(5)

    if len(dirname(1)) >= 1 then
        do
            text(5) 'linie
            Locate (hoehe - 1), 1 : input "Number: ",c
        if len(dirname(c)) >=1 then
            text(3) 'accepted
            dirs = dirname(c)
            exit do
        elseif c = 0 then
            CHDIR ".."
            exit do
        else
            text(4) 'false'
            getkey
        end if
        loop
    else
         text(5) 'linie
         locate (hoehe - 1), 1 : Print "No Directorys";
    end if
    getkey
    return dirs
end function

function file() as string
    cls
    dim files as string
    dim filename(1 to 50) as string
    dim as integer i = 1
    dim as integer c
    locate 1, 1 : PRINT "MuhEdit Filechooser";
    locate 2, 1 : Print String(50, asc("_"))
    locate 3,1
    filename(1) = DIR("*.txt",0) ' das erste verzeichnis
    do                          ' alle anderen =)
        if filename(i) <> "."  then
            print i & ") \" & filename(i)
        end if
        i +=1
        if i = 46 then exit do
        filename(i) = DIR("")
    LOOP WHILE LEN(filename(i)) ' solange noch ein nicht gelistetes Verzeichnis existiert

    text(5)
    if len(filename(1)) >= 1 then
        do
            text(5) 'linie
            Locate (hoehe - 1), 1 : input "Number: ",c
        if len(filename(c)) >=1 then
            locate (hoehe - 1), 1 : Print String(50, asc(" "));
            text(3) 'accepted
            files = filename(c)
            exit do
        else
            text(4) 'false
            getkey
        end if
        loop
    else
         text(5) 'linie
         locate (hoehe - 1), 1 : Print "No files";
    end if
    getkey
    return files
end function

function speichern() as string
    dim seite as string
    dim x as integer
    cls
    text 6 'linie
    if len(seite) <> 0 then
        seite = eingabe("Filename:",seite,hoehe-1,1)
    else
        seite = eingabe("Filename:","example.txt",hoehe-1,1)
    end if

    OPEN seite FOR OUTPUT AS #1
    For x = 3 to UBound(TZeile)
        PRINT #1, rtrim(tzeile(x)) 'ungetestet!!!!!!
    next
    CLOSE #1
    text(3) 'accepted
    getkey
    return seite
end function

sub laden()
    dim files as string
    dim as integer i = 2
    dim as integer X
    seite = file()

    redim tzeile(0) as string
    OPEN seite FOR INPUT AS #1
    while not EOF(1)
        i += 1
        REDIM Preserve tzeile(i) AS STRING
        line INPUT #1, tzeile(i)
    wend
    CLOSE #1
    cls
end sub

sub angleichen()
    if ubound(tzeile) < zeile + A then
        redim preserve tzeile(zeile + A) as string
    end if
end sub


sub Text(ByVal Maeh As Integer)
    select case maeh
    case 1:
        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 "File: "& seite &" | Open another file = F2";
    case 2:
        locate (hoehe - 1), 1 : Print String(50, asc(" "));
    case 3:
        locate (hoehe - 1), 1 : Print String(50, asc(" "));
        Locate (hoehe - 1), 1 : Print "Accepted";
        locate 3,1
    case 4:
        locate (hoehe - 1), 1 : Print String(50, asc(" "));
        Locate (hoehe - 1), 1 : Print "False";
        locate 3,1
    case 5:
        Locate (hoehe - 2),1 : Print String(50, asc("_")):
    case 6:
        locate 1, 1           : PRINT "MuhEdit Saver" ;
        locate 2, 1           : Print String(50, asc("_"));
        Locate (hoehe - 2),1 : Print String(50, asc("_"));
    case else
        exit sub
    end select
end sub


'-------------------------------------------------'
'------------------------hauptprogramm------------'
dirs = curdir
screenres 400,400
COLOR 0, 15
CLS
text(1)
locate 3, 0
DO
    angleichen()
    anzeige(tzeile(), A, 1)
    DRAW STRING ((spalte-1)*8 , (zeile -1)*8), "_",  'Cursor anzeigen
    'auf eingabe warten:
    do : sleep 1
    getmouse mspalte, mzeile,,buttons
    mzeile = mzeile / 8
    if buttons >= 1 then
            zeile = mzeile
            spalte = mspalte / 8
    end if
    d=inkey:loop until d<>"" or (buttons >= 1 and mzeile <= (hoehe - 3) and mzeile > 3 )
    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
            if A > 0 then A -= 1
        end if
    case 80:                         'unten
        if zeile < (hoehe - 3) then
            zeile += 1
        else
            A += 1
        end if
    case 75:                         'links
        if spalte>1 then                        'nicht am zeilenanfang
            L = len(tzeile(zeile +A))
            if L < spalte then
                'print chr(32)
            end if
            spalte-=1
        else                                    'am zeilenanfang
            if zeile > 3 then
                zeile -= 1
                spalte = 1
            else
                if A > 0 then A -= 1
            end if
        end if
    case 77:                           'rechts
        if spalte < 50 then
            tzeile(zeile +A) += chr(32)
            spalte += 1
        elseif spalte = 50 and zeile < (hoehe - 3) then
            zeile += 1
            spalte = 1
        else
            A += 1
            spalte = 1
        end if
    case 107:                        'das X oben
        exit do
    case 62:                            'F4 (verzeichnis wechseln)
        dirs = directory()
        chdir (dirs)
        text(1)
    case 61:                          'seite speichern(F3)
        seite = speichern()
        text(1)
    case 60:                          'Laden (F2)
        laden()
        text(1)
    case 82:                            'einfügen
        if einf = 1 then
            einf = 0
        else
            einf = 1
        end if
    case 73:
        if A > 0 then
            A -= 1
        end if
    case 81
        a += 1
    end select

    'Zweiter case-block
    if ascL <> 255 then
    select case ascL
        case 8:                               'backspace
        if spalte <> 1 then                        'nicht am zeilenanfang
            spalte-=1
            locate zeile,spalte
            L = len(tzeile(zeile +A))
            if L >= spalte then
                rest = right(tzeile(zeile + A), (L - spalte))
                MID(tzeile(zeile + A), spalte, len(rest)) = rest
                tzeile(zeile+A)=left(tzeile(zeile+A),len(tzeile(zeile+A))-1)
            else
                tzeile(zeile +A)=left(tzeile(zeile +A),len(tzeile(zeile +A))-1)
            end if
        else                                    'am zeilenanfang
            if zeile > 3 then
            zeile -= 1
                if L >= spalte then
                    rest = right(tzeile(zeile +A), (L - spalte))
                    MID(tzeile(zeile +A), spalte, len(rest)) = rest
                    tzeile(zeile +A)=left(tzeile(zeile +A),len(tzeile(zeile +A))-1)
                else
                    tzeile(zeile +A)=left(tzeile(zeile +A),len(tzeile(zeile +A))-1)
                end if
            else
                if A > 0 then A -= 1
            end if
            spalte = len(tzeile(zeile +A)) +1
        end if
    case 13:                              'enter
        if zeile < (hoehe - 3) then
            zeile += 1
        else
            spalte = 1
            A += 1
        end if
    case 127:
        if L >= spalte then
            rest = right(tzeile(zeile +A), (L - spalte))
            MID(tzeile(zeile +A), spalte, len(rest)) = rest
            tzeile(zeile +A) = left(tzeile(zeile +A),len(tzeile(zeile +A))-1)
        end if
    case 19:
        seite = speichern()
        text(1)
    case 27:                              'escape
        exit do
    case else:
        L = len(tzeile(zeile + A))
        if L < spalte then
            for i = 1 to spalte
            tzeile(zeile + A) += " "
            next i
        end if

        if spalte >= 50 then
            spalte = 1
            zeile+=1
            if zeile>(hoehe - 3) then A += 1
        end if
        L = len(tzeile(zeile +A))
        if L <= 50 then
        if L >= spalte then
            if einf = 0 then
                MID(tzeile(zeile + A), spalte, 1) = d
            else
                tzeile(zeile +A) = left(tzeile(zeile +A ), spalte -1) + d + right(tzeile(zeile +A), (L - spalte +1) )
            end if
        else
            tzeile(zeile +A) = tzeile(zeile +A) + d
        end if
        end if
        spalte+=1
    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("_"));

text(5)
Locate (hoehe - 1),1
Print "Programming and Idea:                   The_Muh";
getkey
end
'---------------------------------------------------------------
'minimun-todo (bis 1.0 ):
'mehr als 50 spalten (0%)
'Funktionierende Umlaute und sonderzeichen unter Linux
'---------------------------------------------------------------