Ola pessoal,
alguem sabe onde posso conseguir o fonte do memoedit, pois quero efetuar uma alteracao, colocando a linha do cursor em outra cor, melhorando assim as edicoes de arquivos txt puro.
precisava tambem uma forma de conseguir ver 132 colunas na hora da edicao sem rolagem para a direita, facilitando assim a edicao de arquivos com 132 colunas, tentei mudar a fonte etc.. usando alguns comandos em harbour mas nao deu certo...
qualquer dica sera bem vinda...
abracos,
ABEL
editar um txt - memoedit
Moderador: Moderadores
- rochinha
- Administrador

- Mensagens: 4664
- Registrado em: 18 Ago 2003 20:43
- Localização: São Paulo - Brasil
- Contato:
editar um txt - memoedit
Amiguinho,
Uma boa fonte de conhecimento de edição de textos, com acentuação, busca e/ou troca de palavras é o código fonte do PE.PRG do Clipper.
É um editor mais elaborado que o MemoEdit, contando com contador de linhas e colunas e outras coisinhas mais.
Uma boa fonte de conhecimento de edição de textos, com acentuação, busca e/ou troca de palavras é o código fonte do PE.PRG do Clipper.
É um editor mais elaborado que o MemoEdit, contando com contador de linhas e colunas e outras coisinhas mais.
OPS! LINK QUEBRADO? Veja ESTE TOPICO antes e caso não encontre ENVIE seu email com link do tópico para [url=mailto://fivolution@hotmail.com]fivolution@hotmail.com[/url]. Agradecido.
@braços : ? )
A justiça divina tarda mas não falha, enquanto que a justiça dos homens falha porque tarda.
@braços : ? )
A justiça divina tarda mas não falha, enquanto que a justiça dos homens falha porque tarda.
- Pablo César
- Usuário Nível 7

- Mensagens: 5312
- Registrado em: 31 Mai 2006 10:22
- Localização: Curitiba - Paraná
editar um txt - memoedit
Você poderia também tentar implementar a edição ou exibição de arquivo texto através do TBrowse. Aqui no fórum parece que tem 3 exemplos veja neste tópico: https://pctoledo.org/forum/viewto ... 5051#p5051
Um clip-abraço !
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
Pablo César Arrascaeta
Compartilhe suas dúvidas e soluções com todos os colegas aqui do fórum.
Evite enviar as dúvidas técnicas por MPs ou eMails, assim todos iremos beneficiar-nos.
editar um txt - memoedit
ola, pessoal,
estou postando um codigo (Pe.prg) alterado que utilizo para editar arquivos txt,
ainda to tentando mudar a cor da linha onde o cursor estiver posicionado, mas nao consegui. se alguem souber, agradeco desde ja a dica.
estou postando um codigo (Pe.prg) alterado que utilizo para editar arquivos txt,
ainda to tentando mudar a cor da linha onde o cursor estiver posicionado, mas nao consegui. se alguem souber, agradeco desde ja a dica.
Código: Selecionar todos
function arqedit(cFile)
local nKey, lDone, cScreen
//
setmode(35,132) // aumenta a tela para 132 colunas para facilitar alterar
//
Set(_SET_BELL, .f.)
Set(_SET_SCOREBOARD, .f.)
SetKey(28, NIL)
if ( IsColor() )
SETCOLOR("W+/B, GR+/B")
else
SetColor("w/n, n/w")
end
if ( Empty(cFile) )
cFile := ""
elseif ( Rat(".", cFile) <= Rat("\", cFile) )
cFile := cFile + ".con"
end
nMaxRow := Maxrow()
nMaxCol := Maxcol()
nStatCol := nMaxCol - 34
/* create the edit structure */
aEdit := Array(ES_LENGTH)
aEdit[ES_FILE] := Lower(cFile)
aEdit[ES_TEXT] := MemoRead(cFile)
aEdit[ES_TOP] := 0
aEdit[ES_LEFT] := 0
aEdit[ES_BOTTOM] := nMaxRow - 2
aEdit[ES_RIGHT] := nMaxCol
aEdit[ES_WIDTH] := 132
aEdit[ES_TABSIZE] := 4
aEdit[ES_SCROLL] := .f.
aEdit[ES_WRAP] := .t.
aEdit[ES_INS] := Set(_SET_INSERT)
aEdit[ES_ROW] := 1
aEdit[ES_COL] := 0
aEdit[ES_RELROW] := 0
aEdit[ES_RELCOL] := 0
aEdit[ES_CHANGED] := .f.
aEdit[ES_LASTKEY] := 0
aEdit[ES_PATTERN] := ""
cScreen := SaveScreen(0, 0, nMaxRow, nMaxCol)
cls
@ nMaxRow - 1, 0 TO nMaxRow - 1, nMaxCol
//
rA_COR=SETCOLOR()
SET COLOR TO 'R+/B'
//
MSG2( "Arquivo: " + aEdit[ES_FILE] )
SET COLOR TO &rA_COR
//
lDone := .f.
while (!lDone)
DoEditing()
nKey := aEdit[ES_LASTKEY]
do case
case (nKey == K_ALT_S .OR. nkey == 404) // ^TAB
Search()
case (nKey == K_ALT_A)
SearchAgain()
case (nKey == EK_WRITE .OR. nkey == -1) // F2
EditWrite()
case (nKey == EK_QUIT)
lDone := PExit()
case (nKey == EK_WQUIT .OR. nkey == -9) // F10
EditWrite()
lDone := PExit()
otherwise
end
end
if ( IsColor() )
SetColor(",,n")
end
RestScreen(0, 0, nMaxRow, nMaxCol, cScreen)
@ nMaxRow, nMaxCol SAY ""
//
rL_MAXIMIZE=HB_GTINFO( HB_GTI_MAXIMIZED )
setmode(28,80)
//
// restaura tamanho padrao maximo de tela
//
IF .NOT. rL_MAXIMIZE
nWidth := hb_gtInfo( HB_GTI_DESKTOPWIDTH )
nHeight := hb_gtInfo( HB_GTI_DESKTOPHEIGHT )
//
nFontWidth := int(nWidth/92) // /80 // 11 ficou legal // PELO CALC=12
nFontHeight:= int(nHeight/37) // /28 // 18 ficou legal // PELO CALC=27
//
hb_gtInfo( HB_GTI_FONTWIDTH, nFontWidth )
hb_gtInfo( HB_GTI_FONTSIZE, nFontHeight )
ELSE
HB_GTINFO(HB_GTI_MAXIMIZED, .T. )
ENDIF
//
return (NIL)
****
* DoEditing()
*
func DoEditing()
aEdit[ES_WRAP] := .t.
aEdit[ES_TEXT] := MemoEdit( aEdit[ES_TEXT], ;
aEdit[ES_TOP], ;
aEdit[ES_LEFT], ;
aEdit[ES_BOTTOM], ;
aEdit[ES_RIGHT], ;
.t., "ufunc", ;
aEdit[ES_WIDTH], ;
aEdit[ES_TABSIZE], ;
aEdit[ES_ROW], ;
aEdit[ES_COL], ;
aEdit[ES_RELROW], ;
aEdit[ES_RELCOL] ;
)
return (NIL)
****
* Prompt()
*
func Prompt2(cSay, cGet)
local getList := {}, bInsSave, bAltISave
bInsSave := SetKey(K_INS, {|| SetCursor(if( Set(_SET_INSERT, ;
!Set(_SET_INSERT) ), ;
SC_NORMAL, SC_INSERT) ) } ;
)
bAltISave := SetKey(K_ALT_I, SetKey(K_INS))
MSG2(Space(nStatCol))
@ nMaxRow,0 SAY cSay ;
GET cGet ;
Picture "@KS" + Ltrim(Str(nStatCol - (Len(cSay) + 2)))
READ
SetKey(K_INS, bInsSave)
SetKey(K_ALT_I, bAltISave)
aEdit[ES_INS] := Set(_SET_INSERT)
return (cGet)
****
* NewName()
*
func NewName()
local name
name := Prompt2("Novo nome do Arquivo:", PadR(aEdit[ES_FILE], 32))
name := Lower(Ltrim(Rtrim(name)))
if ( !Empty(name) .and. name != aEdit[ES_FILE] )
aEdit[ES_FILE] := name
aEdit[ES_CHANGED] := .t.
end
//
rA_COR=SETCOLOR()
SET COLOR TO 'R+/B'
//
MSG2("Arquivo: " + aEdit[ES_FILE])
SET COLOR TO &rA_COR
//
return (NIL)
****
* xSearch()
*
func xSearch(x)
local nRow, pos, offset, newcol, a
if ( !Empty(aEdit[ES_PATTERN]) )
nRow := aEdit[ES_ROW]
pos := x + MLCToPos(aEdit[ES_TEXT], ;
aEdit[ES_WIDTH], ;
aEdit[ES_ROW], ;
aEdit[ES_COL], ;
aEdit[ES_TABSIZE], ;
aEdit[ES_WRAP] ;
)
offset := pos + At(aEdit[ES_PATTERN],Substr(aEdit[ES_TEXT], pos)) - 1
if ( offset >= pos )
a := MPosToLC(aEdit[ES_TEXT], ;
aEdit[ES_WIDTH], ;
offset, ;
aEdit[ES_TABSIZE],;
aEdit[ES_WRAP] ;
)
aEdit[ES_ROW] := a[1]
newcol := a[2]
aEdit[ES_RELCOL] := aEdit[ES_RELCOL] + newcol - aEdit[ES_COL]
aEdit[ES_COL] := newcol
if ( aEdit[ES_ROW] - nRow <= ;
aEdit[ES_BOTTOM] - aEdit[ES_TOP] - aEdit[ES_RELROW] ;
)
aEdit[ES_RELROW] := aEdit[ES_RELROW] + aEdit[ES_ROW] - nRow
end
MSG2("Localizei ...")
else
MSG2("Nao encontrei esta palavra ...")
end
else
MSG2("")
end
//
rA_COR=SETCOLOR()
SET COLOR TO 'R+/B'
//
MSG2("Arquivo: " + aEdit[ES_FILE])
SET COLOR TO &rA_COR
//
return (NIL)
****
* Search()
*
func Search()
local pattern
pattern := Prompt2("Procura por:", PadR(aEdit[ES_PATTERN], 32))
pattern := Ltrim(Rtrim(pattern))
if ( !Empty(pattern) )
aEdit[ES_PATTERN] := pattern
xSearch(0)
else
MSG2("")
end
//
rA_COR=SETCOLOR()
SET COLOR TO 'R+/B'
//
MSG2("Arquivo: " + aEdit[ES_FILE])
SET COLOR TO &rA_COR
//
return (NIL)
****
* SearchAgain()
*
func SearchAgain()
return (xSearch(1))
****
* ufunc()
*
func ufunc(nMode, nLine, nCol)
local nKey
aEdit[ES_LASTKEY] := nKey := LastKey()
aEdit[ES_ROW] := nLine
aEdit[ES_COL] := nCol
aEdit[ES_RELROW] := Row() - aEdit[ES_TOP]
aEdit[ES_RELCOL] := Col() - aEdit[ES_LEFT]
if (nMode == ME_INIT)
if (aEdit[ES_WRAP])
/* turn off word wrap */
aEdit[ES_WRAP] := .f.
return (ME_TOGGLEWRAP) /* NOTE */
end
SetCursor( if(aEdit[ES_INS], SC_INSERT, SC_NORMAL) )
elseif (nMode == ME_IDLE)
StatMSG2()
else
/* keystroke exception */
if (nMode == ME_UNKEYX)
aEdit[ES_CHANGED] := .t.
end
do case
case (nKey == K_F3)
DisplayHelp()
case (nKey == K_ALT_O .OR. nkey == -29) // ctrl+f10
NewName()
case (nKey == K_INS)
aEdit[ES_INS] := !Set(_SET_INSERT)
SetCursor( if(aEdit[ES_INS], SC_INSERT, SC_NORMAL) )
return (nKey)
case (nKey == K_ALT_I)
aEdit[ES_INS] := !Set(_SET_INSERT)
SetCursor( if(aEdit[ES_INS], SC_INSERT, SC_NORMAL) )
return (K_INS)
case (nKey == K_ALT_S .or. nkey == 404)
/* search */
return (K_CTRL_W)
case (nKey == K_ALT_A)
/* search again */
return (K_CTRL_W)
case (nKey == K_ALT_X)
aEdit[ES_LASTKEY] := EK_QUIT
return (K_CTRL_W)
case (nKey == EK_QUIT)
return (K_CTRL_W)
case (nkey == 28) // F1
SAVE SCREEN TO rT_F3PE
//
rN_L=ROW()
rN_C=COL()
//
rA_COR=SETCOLOR()
SET COLOR TO N/W
//
@ 11,14 TO 23,77
rA_COM=MEMOREAD('COMANDO.TXT')
MEMOEDIT(rA_COM,12,15,22,76,.F.)
SET COLOR TO &rA_COR
//
@ rN_L,rN_C SAY ''
//
RESTORE SCREEN FROM rT_F3PE
case (nKey == EK_WRITE .or. nkey == -1 .or. nkey == -9)
return (K_CTRL_W)
otherwise
end
end
return (0)
****
* EditWrite()
*
func EditWrite()
local lRet
lRet := .t.
if ( aEdit[ES_CHANGED] )
if LEN(ALLTRIM(aEdit[ES_FILE]))=0
name := Prompt2("Nome do Arquivo:", PadR(aEdit[ES_FILE], 32))
name := Lower(Ltrim(Rtrim(name)))
cFile:=name
aEdit[ES_FILE]:=name
ENDIF
MSG2( "Gravando " + aEdit[ES_FILE] )
if ( MemoWrit(aEdit[ES_FILE], aEdit[ES_TEXT]) )
rA_COR=SETCOLOR()
SET COLOR TO G+/B
//
MSG2("Arquivo Gravado com Sucesso - OK")
SET COLOR TO &rA_COR
//
aEdit[ES_CHANGED] := .f.
//
else
MSG2("Erro ao Gravar Arquivo, Verifique ...")
lRet := .f.
end
else
MSG2("Nenhuma informacao foi Alterada, Verifique !")
end
INKEY(2)
//
rA_COR=SETCOLOR()
SET COLOR TO 'R+/B'
//
MSG2( "Arquivo: " + aEdit[ES_FILE] )
//
SET COLOR TO &rA_COR
return (lRet)
****
* MSG2()
*
func Msg2(text)
static oldLength := 0
if (oldLength != 0)
@ nMaxRow, 0 SAY Replicate(" ", oldLength)
end
@ nMaxRow, 0 SAY text
oldLength := Len(text)
return (NIL)
****
* StatMSG2()
*
func StatMSG2()
local cLine, cCol, nCtype, nRow, nCol
cLine := PadR( LTrim(Str(aEdit[ES_ROW])), 6 )
cCol := LTrim( Str(aEdit[ES_COL]+1) )
nCtype := SetCursor(0)
nRow := Row()
nCol := Col()
@ nMaxRow, 64 SAY 'F2-Salva F3-Help' COLOR 'G+/B'
//
@ nMaxRow, nStatCol SAY "Lin " + cLine + "Col " + cCol +" " COLOR'GR+/B'
DevPos(nRow, nCol)
SetCursor(nCtype)
return (NIL)
****
* PExit()
*
func PExit()
local c, lRet, nCtype
lRet = .t.
if ( aEdit[ES_CHANGED] )
nCtype := SetCursor(SC_NORMAL)
//
if LEN(ALLTRIM(aEdit[ES_FILE]))=0
name := Prompt2("Nome do Arquivo:", PadR(aEdit[ES_FILE], 32))
name := Lower(Ltrim(Rtrim(name)))
cFile:=name
aEdit[ES_FILE]:=name
ENDIF
//
MSG2('Deseja Salvar "' + aEdit[ES_FILE] + '" (S/N) ?' )
while ( !((c := Upper(Chr(InKey(0)))) $ ("SN" + Chr(K_ESC))) )
end
if ( c == "S" )
lRet := EditWrite()
else
if ( c != "N" )
rn_segchance=alert2('VERMELHO','Voce vai perder as alteracoes feitas ...',{"$Salva","$Nao Salva"})
if rn_segchance=1
lRet:=EditWrite()
else
lRet := .f.
endif
end
MSG2("")
end
SetCursor(nCtype)
end
return (lRet)
****
* DisplayHelp()
*
func DisplayHelp()
local cScreen := SaveScreen(0, 0, MaxRow(), MaxCol()), nCtype
cls
@ 0, 1 say "editor - Help"
@ 1, 0 to nMaxRow - 1, nMaxCol
@ 2, 2 say "Comandos Basicos │ Comandos Avancados "
@ 3, 2 say " │ "
@ 4, 2 say " F2 - Grava e continua │ ^E - Sobe linha "
@ 5, 2 say " F10 - Grava e Fecha │ ^X - Desce linha "
@ 6, 2 say "^F10 - Altera Nome Arq.Antes de Salvar │ ^S - Retorna caracter "
@ 7, 2 say " │ ^D - Avanca caracter "
@ 8, 2 say " Home - Inicio da linha │ ^A - Retorna palavra "
@ 9, 2 say " End - Fim da linha │ ^F - Avanca palavra "
@ 10,2 say " │ "
@ 11,2 say "^Home - Inicio da Janela │ ^Y - Apaga linha "
@ 12,2 say "^End - Fim da Janela │ ^T - Apaga palavra a direita "
@ 13,2 say " │ "
@ 14,2 say "PgUp - Pagina anterior │ ^Tab - Procura uma palavra "
@ 15,2 say "PgDn - Proxima pagina │ Alt+A - Procura novamente (prox) "
@ 16,2 say " │ "
@ 17,2 say "^PgUp - Vai para o Inicio do arquivo │ "
@ 18,2 say "^PgDn - Vai para o Fim │ "
@ 19,2 say " │ "
@ 20,2 say " F1 - Exibe os comandos # (contrato) │ "
@ 21,2 say " │ "
@ 22,2 say " │ "
@ nMaxRow, 1 say "Pressione Qualquer Tecla para Voltar ........"
nCtype := SetCursor(SC_NORMAL)
Inkey(0)
SetCursor(nCtype)
RestScreen(0, 0, nMaxRow, nMaxCol, cScreen)
return (NIL)
