Lord_Dark199

Redak

May 25th, 2015
296
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #coding:utf-8
  2. try:
  3.     import appuifw2
  4.     import os
  5.     import e32
  6.     import powlite_fm_2
  7. except:
  8.     import appuifw
  9.     import os
  10.     appuifw.note((ru("У вас не хватает модулей")), "error")
  11.     os.abort()
  12.  
  13.  
  14. ru=lambda x: x.decode('utf-8')
  15. appuifw2.app.title = u"Redak"
  16. appuifw2.app.screen = "normal"
  17. def quit():
  18.         if appuifw2.query(ru("Хотите выйти?"), "query") == 1: appuifw.app.set_exit()
  19. appuifw2.app.exit_key_handler = quit
  20.  
  21. appuifw2.app.body = text = appuifw2.Text(move_callback=None, edit_callback=None, skinned=False,
  22.     scrollbar=True, word_wrap=True, t9=True, indicator=True, fixed_case=False)
  23.  
  24. def save():
  25.     pathmanager=powlite_fm_2.manager()
  26.     path1=pathmanager.AskUser(find="dir")
  27.     path2=appuifw2.query(ru("Введите имя файла+расширение"), "text")
  28.     fullpath=path1+path2
  29.     if os.path.exists(fullpath)==1:
  30.         rewrite=appuifw2.query(ru("Такой файл существует!Перезаписать?"), "query")
  31.         if rewrite==1:
  32.             f=open(fullpath, "w")
  33.             content = text.get().replace(u"\u2029", u"\r\n")
  34.             encontent = content.encode("UTF-8")
  35.             f.writelines(encontent)
  36.             f.close()
  37.             appuifw2.note(ru("Файл сохранен!"), "conf")
  38.         elif rewrite==0:
  39.             appuifw2.note(ru("Файл не сохранен!"), "error")
  40.     elif os.path.exists(fullpath)==0:
  41.         f=open(fullpath, "w")
  42.         content = text.get().replace(u"\u2029", u"\r\n")
  43.         encontent = content.encode("UTF-8")
  44.         f.writelines(encontent)
  45.         f.close()
  46.         appuifw2.note(ru("Файл сохранен!"), "conf")
  47.    
  48. def clear():
  49.     text.clear()
  50.  
  51.  
  52.  
  53. def toendtext():
  54.     a=text.len()
  55.     text.set_pos(a)
  56.  
  57. #Пока не робит, ну и пофиг!
  58. Главное что остальное робит!
  59. def openfile():
  60.     open2 = text.len()
  61.     if open2 > 0:
  62.         rewritefile = appuifw2.query(ru("Вы уже чего то написали. Открыть новый файл?"), "query")
  63.         if rewritefile == 1:
  64.             text.clear()
  65.             fileman=powlite_fm_2.manager()
  66.             ope=fileman.AskUser()
  67.             afn=open(str(ope))
  68.             text.add(ru(str(afn)),)
  69.         elif rewritefile == 0:
  70.             pass
  71.     fileman=powlite_fm_2.manager()
  72.     ope=fileman.AskUser()
  73.     afn=open(ope)
  74.     text.add(ru(str(afn)))
  75.  
  76.  
  77. menu = [
  78. (ru("Открыть файл"), openfile),
  79. (ru("Сохранить файл"), save),
  80. (ru("Очистиь поле"), clear),
  81. (ru("В конец текста"), toendtext)]
  82. appuifw2.app.menu=menu
  83.  
  84.  
  85. lock = e32.Ao_lock()
  86. os.abort = lock.signal
  87. lock.wait()
Advertisement
Add Comment
Please, Sign In to add comment